Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1559 How can I have a link make the current page the users home page?

You are here: irt.org | FAQ | JavaScript | Bookmark | Q1559 [ previous next ]

Try:

<script language="JavaScript"><!--
isIE = false;
navVer = navigator.appVersion;
ver = parseFloat(navVer);
IEPos = navVer.indexOf('MSIE');
if (IEPos !=-1) {
  isIE = true;
  ver = parseFloat(navVer.substring(IEPos+5,navVer.indexOf(';',IEPos)));
}

isIE5up = (isIE && ver >= 5);

function setNSHomepage(URL) {  // this HAS to be signed if it is to run on the web
  var Text = '';
  Text += 'Due to Netscapes security handling, making this page your homepage, will show you a dialog with a warning.\n';
  Text += 'If you do not wish to grant this site the access to your browser settings,';
  Text += ' you can manually copy the current location and paste it in the location field in Edit / Preferences / Navigator.';
  if (confirm(Text)) {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
    navigator.preference('browser.startup.homepage',URL);
  }
}
//--></script>

<a href="javascript:;"
onClick="HomePage = top.location.href;
if (document.layers) setNSHomepage(HomePage);
else if (isIE5up) {
   this.style.behavior='url(#default#homepage)';
   this.setHomePage(HomePage);
}
else alert('Sorry, not supported in this browser,\n please change this setting
manually');
return false;">Make this page your homepage</a>

This can be a little automated by executing what is in the onClick in another event handler like onLoad (but people will get annoyed with you if you do)

Feedback on 'Q1559 How can I have a link make the current page the users home page?'

©2018 Martin Webb