关于Firefox下JavaScript设置主页
2008-07-21 19:58:25 来源:WEB开发网在IE下,我们可以轻松使用以下代码来实现设置主页:
<a class="chlnk" style="cursor:hand;font-weight:bold;color:#004080;font-family:Verdana" HREF >Click here to make devdao.com your default homepage!</a>
然而,在Firefox下是不行的
要使用脚本在firefox下设置主页,首先必须确认在浏览器的“about:config”中,把
signed.applets.codebase_PRincipal_support
设置成true
然后使用以下脚本:
<script language="javascript">
function setHomepage()
{
if (document.all)
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage('http://www.asp.net/130.aspx');
}
else if (window.sidebar)
{
if(window.netscape)
{
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch(e)
{
alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage','http://www.asp.net/130.aspx');
}
}
</script>
<input type="button" value="set home page" />
Tags:关于 Firefox JavaScript
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接