在IE下,我们可以轻松使用以下代码来实现设置主页:
<a class="chlnk" style="cursor:hand;font-weight:bold;color:#004080;font-family:Verdana" HREF onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.devdao.com');">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" onclick="setHomepage();" />
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |