我正在尝试使用以下代码在Safari中添加书签页面。但是没有工作
$("#Bookmark").click(function (e) {
e.preventDefault();
var bookmarkUrl = this.href;
var bookmarkTitle = this.title;
if (window.sidebar) { // For Mozilla Firefox Bookmark
window.sidebar.addPanel(bookmarkTitle, bookmarkUrl, "");
} else if (window.external || document.all) { // For IE Favorite
window.external.AddFavorite(bookmarkUrl, bookmarkTitle);
} else if (window.opera) { // For Opera Browsers
$("a.jQueryBookmark").attr("href", bookmarkUrl);
$("a.jQueryBookmark").attr("title", bookmarkTitle);
$("a.jQueryBookmark").attr("rel", "sidebar");
} else { // for other browsers which does not support
alert('Your browser does not support this bookmark action');
return false;
}
});
答案 0 :(得分:0)
您无法强制用户在Safari中将网站添加到书签中。
解决方案是告知用户要添加到书签的快捷键:https://stackoverflow.com/a/10033250/2219239