Bookmark this page JavaScript

Posted: May 27th, 2008 | Author: Henrie Media Inc. | Filed under: JavaScript | 3 Comments »

ComputerHere is a handy “Bookmark this page” JavaScript I wrote that will work in Internet Explorer, Firefox, Safari and most of the major web browser. The script will prompt the user to bookmark the page they are on. Here is what you need to use this script on your website.

Put the following code between the <head></head> tags of your webpage -

<script>
function bookmark(title,url){
if(window.sidebar)
window.sidebar.addPanel(title,url,”");
else if(window.opera && window.print){
var elem = document.createElement(‘a’);
elem.setAttribute(‘href’,url);
elem.setAttribute(‘title’,title);
elem.setAttribute(‘rel’,'sidebar’);
elem.click();
}
else if(window.external)
window.external.AddFavorite(url,title);
}
</script>

Put the following script in your Bookmark this page link (this can be a text or image link) -

<a href=”javascript:bookmark(‘Henrie Media Inc.’,’http://www.henriemedia/’);”>Bookmark this page</a>

Make sure you change the parameters (‘title’, ‘url’) to the ‘url’ you want to bookmark and the ‘title’ you want the bookmark to say. In my example the ‘url’ is “http://www.henriemedia.com” and the ‘title’ is “Henrie Media Inc.”

That’s it! Your are off and bookmarking. Please leave a comment if you find this post to be helpful.

Print, Email, Share, Enjoy!
  • Print
  • email
  • Twitter
  • Facebook
  • Digg
  • MySpace
  • Mixx
  • del.icio.us
  • Technorati
  • StumbleUpon

3 Comments on “Bookmark this page JavaScript”

  1. 1 John K said at 3:27 pm on July 18th, 2008:

    Sorry mate, but this doesn’t work in Safari as advertised.

  2. 2 Kyle Henrie said at 5:16 pm on July 18th, 2008:

    I just tried this on Safari for the PC and it worked. What version of Safari and platform are you using?

  3. 3 Kyle Henrie said at 2:07 pm on August 14th, 2008:

    I just re-checked this code with Safari and it does not work. I will post a solution once I find one – or you can post one if you have one. Thank you.