Most web browsers like Firefox (Ctrl+D), Opera (Ctrl+T) and IE (Ctrl+D) provide keyboard shortcuts to enable users bookmark their favorite pages. But not every visitor is a power user, so for them, you can add a quick “Bookmark this page” link in all your pages. Clicking on the link prompts the user with a dialog box to add the specified URL to the Favorites list. The following version of “Add to Favorites” javascript code works across IE, Mozilla Firefox and Opera Browsers.
<script language="JavaScript1.2" type="text/javascript">
function
CreateBookmarkLink()
{
    title = "Webpage Title";

    url = "Webpage URL";

    if (window.sidebar)
    {
        // Mozilla Firefox Bookmark
        window.sidebar.addPanel(title, url,"");
    }
    else if ( window.external )
    {
        // IE Favorite
        window.external.AddFavorite( url, title);
    }
    else if (window.opera && window.print)
    {
        // Opera Hotlist
        return true;
    }
}

if (window.external)
{
    document.write('<a href = "javascript: CreateBookmarkLink();">Add to Favorites</a>');
}
else if (window.sidebar)
{
    document.write('<a href = "javascript: CreateBookmarkLink();">Bookmark Page</a>');
}
else if (window.opera && window.print)
{
    document.write('<a href = "javascript: CreateBookmarkLink();">Add Bookmark</a>');
}

</script>
If your audience are visiting the site from a different web browser or if javascript is not supported , the bookmark link is not displayed.

Leave a Reply

Your email address will not be published. Required fields are marked *