Answer
In the context of the World Wide Web, a bookmark(favorites) is a locally stored Uniform Resource Identifier (URI). All modern web browsers include bookmark features. The key to answering this question is mentioning X-browser compatibility. The implementations can vary from very simple to more complex. Here is one of the approaches which is using window.sidebar and window.external objects for IE and Firefox and createElement for Opera.
In the context of the World Wide Web, a bookmark(favorites) is a locally stored Uniform Resource Identifier (URI). All modern web browsers include bookmark features. The key to answering this question is mentioning X-browser compatibility. The implementations can vary from very simple to more complex. Here is one of the approaches which is using window.sidebar and window.external objects for IE and Firefox and createElement for Opera.
function Bookmark(title, url)
{
if (window.sidebar)
{
window.sidebar.addPanel(title, url,"");
return true;
}
if( window.external)
{
window.external.AddFavorite( url, title);
return true;
}
if(window.opera && window.print){
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
return true;
}
return false;
}