Just try this crossbrowser code
function addBookmark(title, url, obj){
if (!url) url = location.href;
if (!title) title = document.title;
if ((typeof window.sidebar == "object") &&
(typeof window.sidebar.addPanel == "function"))
window.sidebar.addPanel (title, url, "");//Gecko
else if (document.all)
window.external.AddFavorite(url, title); //IE4+
else if (window.opera && document.createElement) {
obj.setAttribute('rel','sidebar');
obj.setAttribute('href',url);
obj.setAttribute('title',title);
}
else {
alert("Your browser does not support bookmarks
Press ctrl+D (ctrl+T for old Opera);");
return false; //IF Opera 6
}
return true;
}
Usage: <a href="#" onclick="addBookmark('google','http://google.com', this);">
Bookmark us!
</a>
or
var a = document.getElementsByTagName('a')[0]; if(a.addEventListener) { a.addEventListener("click", function() { addBookmark('google','google.com', a); return false; }, false); } else if (a.attachEvent) { a.attachEvent("onclick", function() { addBookmark('google','google.com', a); return false; });}
It works for me (Opera 10.00)