Bookmark Code That Works Across Browsers (Mozilla and IE)?

Discussion in 'JavaScript' started by micksss, May 9, 2008.

  1. #1
    I have searched everywhere and I can't find the correct code for users to create a bookmark that works in both Mozilla and Internet Explorer.

    The closest thing I have found is below but it makes the bookmark open up in a side window in Mozilla Firefox. Does anyone out there know how to do this without the page opening up in the sidebar but the main window?

    Thanks!

    This code goes in the <head> section of the page.

    <script type="text/javascript">

    function bookmarksite(title,url){
    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>

    Then where ever you want the bookmark link to be use this code:

    <a href="javascript:bookmarksite('title_of_site', 'url_of_site')">Bookmark Us</a>

    There has to be someone out there who has figured this thing out :)

    Thanks!
     
    micksss, May 9, 2008 IP
  2. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #2
    remove this line and try it

    "window.sidebar.addPanel(title, url, "");"
     
    crath, May 12, 2008 IP
    micksss likes this.
  3. micksss

    micksss Notable Member

    Messages:
    4,427
    Likes Received:
    268
    Best Answers:
    1
    Trophy Points:
    285
    #3
    Thanks for your idea but it does not work.

    Anyone else :)
     
    micksss, May 13, 2008 IP
  4. crath

    crath Well-Known Member

    Messages:
    661
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    100
    #4
    When i test the code in firefox, it does not make a sidebar window :S
     
    crath, May 13, 2008 IP
  5. micksss

    micksss Notable Member

    Messages:
    4,427
    Likes Received:
    268
    Best Answers:
    1
    Trophy Points:
    285
    #5
    When I test the code without this line

    "window.sidebar.addPanel(title, url, "");"

    It doesn't do anything for me in FireFox. Maybe I'm missing something else here. I'll mess around with it some more. Thanks for you reply.
     
    micksss, May 17, 2008 IP
  6. dcristo

    dcristo Illustrious Member

    Messages:
    19,776
    Likes Received:
    1,200
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    7
    #6
    Did you find a solution mate?
     
    dcristo, Jan 28, 2009 IP
  7. dudes

    dudes Well-Known Member

    Messages:
    441
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #7
    Hi,
    Any one that fix this problem can you please post it here.

    thanks in advance.
     
    dudes, Feb 16, 2009 IP
  8. micksss

    micksss Notable Member

    Messages:
    4,427
    Likes Received:
    268
    Best Answers:
    1
    Trophy Points:
    285
    #8
    I haven't yet... Still does the sidebar thing...
     
    micksss, Feb 16, 2009 IP
  9. Str82u

    Str82u Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    For anyone that might happen to read this thread, I grabbed the code "AS-IS" and it works fine for IE8 and Firefox 3.5.7. Safari and Chrome showed no sign of doing it with that or the old style script:bookmark....
     
    Str82u, Jan 19, 2010 IP