<script>
function Bookmark() {
alert(navigator.userAgent);
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(location.href, document.title, "");
}
else if (window.external) { // IE Favorite
window.external.AddFavorite(location.href, document.title);
}
else if (window.opera && window.print) {
alert("ASAS");
var e = document.createElement('a');
e.setAttribute('href', location.href);
e.setAttribute('title', document.title);
e.setAttribute('rel', 'sidebar');
e.click();
}
}
</script>
<a href="#" onclick="Bookmark()">Bookmark</a>
我有一个脚本让用户点击为页面添加书签。它在IE中运行正常,但它在Firefox24.0版本中不起作用。它向我显示错误window.sidebar.addPanel不是一个函数。任何人都知道上述代码出了什么问题。请帮忙!!!非常感谢。
答案 0 :(得分:4)
addPanel
was removed from Firefox但您可以改为使用标记:
<a href="http://stackoverflow.com" title="Stack Overflow" rel="sidebar">Bookmark me</a>