Bookmark Site script

This is a cross browser (Firefox 1.x+, IE4+ and Opera7+) script for allowing the user to easily bookmark your site, by clicking on a link on the page.

 

<script type=”text/javascript”>
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, “”);
else if(window.opera && window.print){ // opera
var elem = document.createElement(‘a’);
elem.setAttribute(‘href’,url);
elem.setAttribute(‘title’,title);
elem.setAttribute(‘rel’,’sidebar’);
elem.click();
}
else if(document.all){// ie
window.external.AddFavorite(url, title);
}
else if (navigator.appName==”Netscape”) {
alert(“Please click OK, then press <Ctrl-D> to bookmark this page.”);
}
}
</script>

 

Step 2: Create either an image or text link that will be used as the Bookmark Site link. For the href attribute, use the following code:

javascript:bookmarksite('title_of_site', 'url_of_site')

Here’s an example:

<a href=”javascript:bookmarksite(‘Karuppasamy\’s site’, ‘http://www.karuppasamy11486.com&#8217;)”>Bookmark this site!</a>

Remember, if your site’s title contains apostrophes, they need to be backslashed when entered:

<a href=”javascript:bookmarksite(‘karuppasamy\’s Place’, ‘http://www.google.com&#8217;)”>Bookmark this site!</a>