Search code examples
javascriptasp.net.netbookmarks

Create bookmark with a query string on browsers


I want to create "Bookmark Me" link button on my web site. I am using below javascript code to create the bookmark on browser.

I want to pass some query-string (arg) to the URL. But this doesn't work properly with most of browsers. Is there any better way to do this?

    function CreateBookmark(arg) {
        try {
            var title = "MyWebSite";
            var url = "http://www.MyWebSite.com/" + arg;
            if (window.sidebar) { //mozilla
                window.sidebar.addPanel(title, url, '');
            }
            else if (window.external && window.external.AddFavorite!=null && document.all) {
                window.external.AddFavorite(url, title);
            }
            else {
                // But, this doesn't take the url with query string
                alert('Press ctrl+d to bookmark after you click OK');
            }

        }
        catch (ex) { alert(ex); }
    }

Solution

  • There is no way to implement this because of security restrictions.