首页 > 网站 > WEB开发 > 正文

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

2024-04-27 13:52:56
字体:
来源:转载
供稿:网友

首先,你要在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.VeVb.com/');
}
</script>
</body>
</html>

http://www.VeVb.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.VeVb.com")'>favorite</a>

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表