原来一直用的设为首页、加入收藏代码如下: 
<a href="#" title="设为首页" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.easway.net')">设为首页</a> <a href="#" title="加入收藏" onclick="window.external.addFavorite('http://www.easway.net','武汉亿万互联')">加入收藏</a> 
这段代码在IE中使用正常,但是在火狐中失效,于是整理了一个兼容IE和Firefox的设为首页、加入收藏代码,并且自动获得当前页面的网址和title,使用起来方便多了,好了,上代码: 
<script type="text/javascript"> function addFav(){   // 加入收藏夹  if (document.all) {    window.external.addFavorite(window.location.href, document.title); } else if (window.sidebar) {    window.sidebar.addPanel(document.title, window.location.href, ""); } } 
function setHomepage(){   // 设置首页  if (document.all) {    document.body.style.behavior = 'url(#default#homepage)';    document.body.setHomePage(window.location.href); } else if (window.sidebar) {    if (window.netscape) {     try {      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");     } catch(e) {      alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");     }    } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);    prefs.setCharPref('browser.startup.homepage', window.location.href); } } </script> <a href ="javascript:void(0)" onclick ="setHomepage()"> 设为首页 </a>  <a href="javascript:void(0)" onclick ="addFav()"> 加入收藏 </a>  |