Created
June 28, 2011 04:24
-
-
Save fuhoi/1050486 to your computer and use it in GitHub Desktop.
javascript-set-homepage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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