SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Location
    Rudgwick, UK
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Decent function for cross browsers "bookmark" feature?

    Hi,

    I'm trying to setup a "bookmark this site" link , but for some reason I can't get the code working. I've found this online, which works fine in FF, but not IE:

    Code:
    <script type="text/javascript"> 
    function bookmark_us(url, title){
    if (window.sidebar) // firefox
     window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
     var elem = document.createElement('a');
     elem.setAttribute('href',url);
     elem.setAttribute('title',title);
     elem.setAttribute('rel','sidebar');
     elem.click();
    }
    else if(document.all)// ie
     window.external.AddFavorite(url, title);
    }
    </script>
    Is anyone aware of a better script, which works across the different browsers?

    TIA

    Andy

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,593
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Mine at Unobtrusive Add to Favourites works for IE, Firefox, and Opera and hides the link completely in other browsers so that you don't end up with a broken link.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Addict
    Join Date
    Sep 2008
    Location
    Rudgwick, UK
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Mine at Unobtrusive Add to Favourites works for IE, Firefox, and Opera and hides the link completely in other browsers so that you don't end up with a broken link.
    Thanks, just gave it a go in FF 4, and no show on their demo page =) No problem though, as I found another option which seems to work:

    My Website Designers Blog» Blog Archive » “Bookmark this page” usingjQuery, for IE and Firefox

    Thanks for the reply though

    Cheers

    Andy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •