JavaScript bookmark

Updated: 01/31/2019 by Computer Hope
javascript bookmark

Example

The source code below adds the link above for viewers of your web page to add your page to their bookmarks. This code only works in Internet Explorer, but still displays a message saying to bookmark your site in Netscape.

Source code

<p><script type="text/javascript">
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) { var url="https://www.computerhope.com/";
var title="Computer Hope";
document.write('<a href="javascript:window.ext');
document.write('ernal.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Add our site to your favorites!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Add our site to your favorites!</a>');
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += " (Ctrl-D)";
document.write(msg);
}
</script></p>