首页 > 精选文章 > HTML&CSS > 正文

在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("此操作被浏览器拒绝! 请在浏览器地址栏输入“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','http://www.itlearner.com/');
}
</script>
</body>
</html>

http://www.itlearner.com改成你自己的网址


没有发现可以直接修改成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://www.itlearner.com")'>favorite</a>

原文:http://dian-lv.com.cn/post/108.html

  • 上一篇:商业周刊:阿里巴巴上市将缓解雅虎中国困境
  • 下一篇:Firefox 加速技巧
  • 了解这些字:在的意思 下的意思 设的意思 为的意思 首的意思 页的意思 的的意思 解的意思