在FireFox下设为首页的解决方法

首先,你要在FF浏览器的地址栏里输入:about:config  设置"signed.applets.codebase_principal_support"选项的值为true

然后照下面的代码做就可以了:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>The setHomePage of Firefox</title>
</head>

<body>
<a href="#" target="_search" onclick="setHomePageInFF()">设为首页</a></p>
<script type="text/javascript">
function setHomePageInFF()
{
//author:猫猫(brothercat)
//date:2006.12.4

  if(window.netscape)
  {
        try { 
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
        } 
        catch (e) 
        { 
          alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
        }
  }

  var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
  prefs.setCharPref('browser.startup.homepage','http://bbs.3dcool.net/');
}
</script>
</body>
</html>

http://bbs.3dcool.net   改成你自己的网址


没有发现可以直接修改成true的。
我想这不是简单的程序问题,这是Firefox的安全机制的问题。如果不经允许就能通过javascript修改客户浏览器的设置,那我想也也没有人会用FF了吧^_^



在FireFox下加入收藏夹的解决方法

ff打开

<SCRIPT LANGUAGE="JavaScript">
<!--
function addFavor(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
//-->
</SCRIPT>
<a href="#" onclick='addFavor("never-online,blueDestiny blog","http://bbs.3dcool.net")'>favorite</a>

posted @ 2007-01-31 18:07  PointNet  阅读(2408)  评论(0编辑  收藏  举报