I wrote this piece of code that works for IE, Firefox, and Opera (unfortunately, it does not work for Google Chrome).
function bookmark() { var title = 'Google'; var url = 'http://google.com'; if (document.all) // Check if the browser is Internet Explorer window.external.AddFavorite(url, title); else if (window.sidebar) //If the given browser is Mozilla Firefox window.sidebar.addPanel(title, url, ""); else if (window.opera && window.print) //If the given browser is Opera { var bookmark_element = document.createElement('a'); bookmark_element.setAttribute('href', url); bookmark_element.setAttribute('title', title); bookmark_element.setAttribute('rel', 'sidebar'); bookmark_element.click(); } }
source share