The code below is working, but the technique is old and probably outdated vis-à-vis the current versions of browsers:
function addFavorite( a, b ) {
title = document.title;
url = document.location;
try {
// Internet Explorer
window.external.AddFavorite( url, title );
}
catch (e) {
try {
// Mozilla
window.sidebar.addPanel( title, url, "" );
}
catch (e) {
// Opera
if( typeof( opera ) == "object" ) {
a.rel = "sidebar";
a.title = title;
a.url = url;
return true;
}
else {
// Unknown
alert( b );
}
}
}
return false;
}
Usage:
<a href="#" title="" onclick="addFavorite(this, 'Pressione Ctrl-D para adicionar a página aos seus favoritos');return false;">
Adicionar aos favoritos
</a>
Question
Is the process in its current form working efficiently or can it be simplified and updated to match the specifications of the current browser versions?