Skip to content

Instantly share code, notes, and snippets.

@fuhoi
Created June 28, 2011 04:24
Show Gist options
  • Save fuhoi/1050486 to your computer and use it in GitHub Desktop.
Save fuhoi/1050486 to your computer and use it in GitHub Desktop.
javascript-set-homepage
function setHomepage(url) {
if (document.all) {
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(url);
} else if (window.sidebar) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch(e) {
alert("Cannot set homepage deu to browser permissions. Enter website manually or if you wish to enable this functionality, enter about:config in your address bar 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',url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment