1

Sorry for what appears to be a novice question, but this is on a website I am working on and am not very familiar with javascript. This function is supposed to allow me to bookmark a page, but it only works in IE and FF, not Chrome or Safari.

function bookmark_us(){
var titleElement = document.getElementsByTagName('title')[0]
if (window.sidebar) // firefox
    window.sidebar.addPanel(document.title, window.location.href, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',window.location.href);
    elem.setAttribute('title',document.title);
    elem.setAttribute('rel','sidebar');
    elem.click();
}
else if(document.all)// ie
    window.external.AddFavorite(location.href, document.title);
}

And here is the image that calls the function:

        <div class="bookmark">
             <a href="javascript:bookmark_us();" onclick=""><img src="images/bookmark_button.png" alt="" /></a>
        </div>

If I am missing any other pertinent code to help this get resolved let me know and I will post it right away. Thank you all in advance!

Peter
  • 427
  • 4
  • 9
  • 37
  • 1
    Have you looked at [Cross Browser Bookmark Add to Favorites](http://stackoverflow.com/questions/3024745/cross-browser-bookmark-add-to-favorites-javascript)? – Joshua Drake May 15 '12 at 14:35
  • Thanks, I just read it. Seems to be in a similar situation to me. A cross browser bookmark is what I'm looking for to. Thanks again. – Peter May 15 '12 at 14:41

0 Answers0