Created
June 28, 2011 00:48
-
-
Save fuhoi/1050233 to your computer and use it in GitHub Desktop.
html-set-homepage
This file contains hidden or 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
<html> | |
<head> | |
<title>JavaScript - Set Homepage</title> | |
</head> | |
<body> | |
<input type="button" value="Set homepage" onclick="setHomepage('http://www.google.com');" /> | |
<script language="javascript"> | |
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 due 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); | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bit of history here