1
一直在寻找“添加到收藏夹”的一段代码好'ol html/js。添加到收藏夹/书签:更新
现在我知道How do I add an "Add to Favorites" button or link on my website?文章。但是,如果大多数浏览器都无法正常工作,那已经过时了。
所以我开始了这一个,看看是否有人有更新的一部分适用于2014年的编码,至少看到给我的客户一个给他们最重要的页面添加书签的机会是不错的。考虑到这一点,最好能接受除当前页面之外的其他页面。如果不是,比原来的要多。
这一个是过时原文:
<script type="text/javascript">
$(function() {
$('#bookmarkme').click(function() {
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(document.title,window.location.href,'');
} else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
window.external.AddFavorite(location.href,document.title);
} else if(window.opera && window.print) { // Opera Hotlist
this.title=document.title;
return true;
} else { // webkit - safari/chrome
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
}
});
});
</script>
不重复。更新,看到我发布的代码就是那个代码。 – Matt
没有必要更新仍然有效的东西(而另一篇文章是2013年8月更新的)......我已经在所有浏览器上测试了这个代码(http://jsfiddle.net/2JXuv/),但Safari浏览器却完美运行。 ..这意味着它变得重复 – LGSon
该代码不起作用。那么,它确实,但不正确。运行FF并获得警报。所以它基本上是无用的代码看到它只会在IE和Opera,两个最少使用的浏览器工作... – Matt