I have following function for bookmarking a website. This function is working in Firefox, but not in Chrome on Mac OS (I didn't test yet IE):
function bookmark(url,title){
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
window.external.AddFavorite(url,title);
} else if (navigator.appName == "Netscape") {
window.sidebar.addPanel(title,url,"");
} else {
alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
}
}
And the link:
<a href="javascript:bookmark('http://www.url.com','Bookmark it')" title="">Bookmark</a>
Can anyone give me any tip, why?
You code only works on old browsers.
You can't create a bookmark with JavaScript on modern browsers, because it's not compliant with the W3C specifications, and it's useless (the user will bookmark your website if he likes it).
But you can add rel="bookmark"
to a link to indicate it should be used as a bookmark.