Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Bookmark Page using Javascript

Have you seen the word Bookmark this page or Add to favourite on websites. There is a small script trick to do this. We will have to write some code in HTML head section and call in body tag

To check the example, Please click on Bookmark this page! or Add to favourites!

Javascript code for these link is given below. Select this code and paste in header section.


<script type="text/javascript" >

      function bookmarksite(title,url)
      {

        if (window.sidebar) // firefox
        window.sidebar.addPanel(title, url, "");
        else if(window.opera && window.print){ // If browser is opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);

        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
      }


      else if(document.all)//  If browser is ie

       window.external.AddFavorite(url, title);

      }

</script>

Now Paste this code in body section.


<a href="javascript:bookmarksite(location.href, location.href)">Bookmark
this site!</a>

Share this article   |    Print    |    Article read by 5240 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles:
Related Interview Questions: No related interview question