Javascript onclick event to create Add to Favorites Bookmark in Aspx Pages C# VB.Net

Developers basically use shortcut command to add a page into favorite list or bookmark list but most of the users does not know how they can add an important page into their favorite list or bookmark list. That’s why if developer add a bookmark link or add to favorite link on important pages so that users can easily bookmark the page. Here in this article i will explain how one can add favorites link or bookmark link in a page using cross browser javascript code. My example will work on Internet explorer, Opera(previous versions) and Mozilla Firefox like below:


Note: For Google Chrome we have no option to implement it by Javascript. Better to guide user to press CTRL + D to bookmark a page.

To complete the example write below Javascript Function:

<script type="text/javascript">
    function Add_Bookmark_Favorite(url, title) {
        if (window.sidebar) { // Mozilla Firefox Bookmark
            //Make sure "Load this bookmark in the sidebar is deselected
            window.sidebar.addPanel(title, url, "");
            return false;
        else if (window.external) { // IE Favorites
            window.external.AddFavorite(url, title);
            return false;
        else if (window.opera && window.print) { // Opera Bookmark
            return !addToFav(url, title)

Now add the below HTML Markup:

<a href="" title="" rel="sidebar" onclick="return Add_Bookmark_Favorite(location.href, document.title);">Bookmark / Add to Favorites</a>

Now run the page and click on the “Bookmark / Add to Favorites” link will popup a window to bookmark this page.

Download Code Example C#        Download Code Example VB.Net

Leave a Reply

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

AlphaOmega Captcha Classica  –  Enter Security Code