Javascript function to set a web page as home page for IE and Firefox Compatible

Bookmark on del.icio.us

To make a page as home page by clicking a link you just have to right this javascript function in you .js file

function setHome()
{
if (document.all)
{
document.body.style.behavior=’url(#default#homepage)’;
document.body.setHomePage(’http://url_of_page.com’);

}
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://url_of_page.com’);
}
}

After adding this you only have to call this javascript method.

<a href=”javascript:setHome();”>make your home page </a>

and that’s all

This is compatible for IE and firefox

  1. No comments yet.

  1. No trackbacks yet.