I have a word as a custom "Add to Favorites" button. Clicking on the word link should add the website's URL to the user browser's favorites (bookmarks). This should work for all browsers, IE7+, FF, Opera, Chrome. As my code is working but i think i lack of something, it doesn't when clicked it will auto bookmarks instead of clicking the dialog alert. Kindly advise
Here my code :
$(function(){
function AddFavorite(sURL, sTitle)
{
try
{
window.external.addFavorite(sURL, sTitle);
}
catch (e)
{
try
{
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e)
{
alert("请使用Ctrl+D进行添加");
}
}
}
$('div.link_r').find('a').on('click',function(){
AddFavorite(location.herf,'新蔡');
return false;
});
HTML :
<div class="link_r">
<a href="#">收藏此页面,开奖即时查看</a>
</div>