Skip to content

Instantly share code, notes, and snippets.

@fuhoi
Created June 28, 2011 00:48
Show Gist options
  • Save fuhoi/1050233 to your computer and use it in GitHub Desktop.
Save fuhoi/1050233 to your computer and use it in GitHub Desktop.
html-set-homepage
<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>
@junkycoder
Copy link

Bit of history here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment