9
是否有任何JavaScript可以在幾乎所有的瀏覽器上都能將網頁設置爲主頁?通用javascript設置主頁功能
我正在使用下面的一個。但它僅適用於即和Mozilla
var flag = false;
function setHomepage(web)
{
if (document.all)
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(web);
}
else if (window.sidebar)
{
if(window.netscape)
{
try
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
flag = true;
}
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");
}
}
if(flag)
{
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',web);
}
}
}