搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

HTML code not working Firefox 29

  • 2 回覆
  • 2 有這個問題
  • 6 次檢視
  • 最近回覆由 Kohei

more options

The following code used to work under older Firefox versions. It still works under IE 8, but not Firefox 29. The purpose of the code is that clicking on "Click Here to bookmark this webpage!" add the URL www.google.com in my bookmarks (i had to replace <> with [])

[html]
[head]
[title]VPSIR VULNERABILITY[/title]
[link rel="stylesheet" type="text/css" href="Themes/Gray/Style.css"]
[/head]
[body link="#0000ff" vlink="#0000ff" alink="#ff0000" bgcolor="#ffffff" text="#000000" class="GrayPageBODY"]
[a class="GrayDataLink" href="Menu.html"]Menu[/a]
[script src="JS/sorttable.js" type="text/javascript"]
[/script]
  
[p][p] 
[script]
   function bookmark(title, url)
   {
      if (window.sidebar) // firefox
      {
         window.sidebar.addPanel(title, url, "");
      }
      else if (window.opera && window.print) // opera
      {
         var element = document.createElement("a");
         element.setAttribute("href", url);
         element.setAttribute("title", title);
         element.setAttribute("rel", "sidebar");
         element.click();
      } 
      else if (document.all) // ie
      {
         window.external.AddFavorite(url, title);
      }
   }
[/script]
[center]
[div style="cursor:pointer"  onclick="bookmark('Google', 'www.google.com')"]
[font size="6"][strong][big]Click Here to bookmark this webpage![/big][/strong][/font][/div]
[/center]
[p]
[/html]
The following code used to work under older Firefox versions. It still works under IE 8, but not Firefox 29. The purpose of the code is that clicking on "Click Here to bookmark this webpage!" add the URL www.google.com in my bookmarks (i had to replace <> with []) <pre><nowiki> [html] [head] [title]VPSIR VULNERABILITY[/title] [link rel="stylesheet" type="text/css" href="Themes/Gray/Style.css"] [/head] [body link="#0000ff" vlink="#0000ff" alink="#ff0000" bgcolor="#ffffff" text="#000000" class="GrayPageBODY"] [a class="GrayDataLink" href="Menu.html"]Menu[/a] [script src="JS/sorttable.js" type="text/javascript"] [/script] [p][p] [script] function bookmark(title, url) { if (window.sidebar) // firefox { window.sidebar.addPanel(title, url, ""); } else if (window.opera && window.print) // opera { var element = document.createElement("a"); element.setAttribute("href", url); element.setAttribute("title", title); element.setAttribute("rel", "sidebar"); element.click(); } else if (document.all) // ie { window.external.AddFavorite(url, title); } } [/script] [center] [div style="cursor:pointer" onclick="bookmark('Google', 'www.google.com')"] [font size="6"][strong][big]Click Here to bookmark this webpage![/big][/strong][/font][/div] [/center] [p] [/html]</nowiki></pre>

由 cor-el 於 修改

所有回覆 (2)

more options

That was removed all the way back in Firefox 23.

If you need to provide a sidebar in Firefox, your choices are to either build an extension or use the social API.

more options

Firefox has never provided an API to add a bookmark from a Web page. window.sidebar.addPanel was a method to add a sidebar panel literally. IE's external.AddFavorite has also been deprecated. You should not use the method.