Javascript function to implement add to favorites/bookmark in Internet Explorer, Mozilla Firefox and Opera 7+.
The below "AddToFavorites()" function can be used to anchor tag to implement Add to favorites/bookmark in Internet Explorer, Mozilla Firefox and Opera.
function AddToFavorites()
{
var title = document.title; var url = location.href;
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'); // required to work in opera 7+
elem.click();
}
else if(document.all) // IE
window.external.AddFavorite(url, title);
}
This function can be used as
<a href="javascript:AddToFavorites();" title="Bookmark this page">Bookmark this page!</a>
This link can be place in any page of your website. Thereby you can reduce the pain of your website user to bookmark or make favorites manually.
lol works awsomely, you wont believe how many site just have crap on that only works with IE and those that claim to work with firefox etc are just fail and dont...any idea wats the code to add a bookmark in google chrome.
does not work in any browser
that`s right it doesn`t work on ff3.5
Thanks for the code.works fine for my requirement