Search code examples
bookmarks

How to make a link that makes the page their homepage or a bookmark?


Is there a simple way to create a link that does either?

Basically, I would like a very simple way to do this. Any suggestions are helpful.


Solution

  • In just IE:

    <a href="javascript:window.external.AddFavorite('http://mysite.com', 'My Site')">Bookmark This Site</a>
    

    In firefox and IE:

    function addBookmark(title, url) {
            if (window.sidebar) { // firefox
                  window.sidebar.addPanel(title, url,"");
            } else if( document.all ) { //MSIE
                    window.external.AddFavorite( url, title);
            } else {
                   alert("Sorry, your browser doesn't support this");
            }
    }
    
    <a href="javascript:addBookmark('My Site','http://www.mysite.com')>Add bookmark</a>