• Categories

  • Archives

    Archive for the ‘Code Library’ Category

    Bookmark this page JavaScript

    By Kyle Henrie | May 27, 2008

    Here 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.

    Topics: Code Library, Technical Support | 3 Comments »