Automatic bookmark script in javascript

Posted by Darren on Jan 18, 2010 in Coding, javascript |

After googling, yahooing and scratching my head – ive now realised that automatic booking in browsers such as Chrome and Safari (including the iphone) simply isn’t possible. However I did find a useful script that takes care of IE, Firefox and Opera – whilst displaying a “helpful” message to others.

function bookmarksite(){
var title = top.document.title;
var url = document.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');
elem.click();
}else if(document.all){ // ie
window.external.AddFavorite(url, title);
} else{
alert("Sorry, we do not support automatic bookmarking for your browser at this time.");
}
}

Tags: , , , , , ,

Reply