从JavaScript添加到浏览器收藏/书签,但对于所有浏览器(我的Chrome不工作)? [英] Add to browser favorites/bookmarks from JavaScript but for all browsers (mine doesn't work in Chrome)?

查看:777
本文介绍了从JavaScript添加到浏览器收藏/书签,但对于所有浏览器(我的Chrome不工作)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助,我使用下面的添加书签到IE和Firefox,但它不工作在Chrome和我没有得到我的错误msg说不支持。

Can anyone help, I am using the following for adding a bookmark to IE and Firefox but its not working in Chrome and I don't get my error msg saying "not supported" either..

任何人都知道一个好的脚本支持所有的浏览器,或者至少回来告诉我它不支持,我可以访问jQuery - 也许有一些方法来检测浏览器

Anybody know of a good script to support ALL browsers or at least to come back and tell me its not supported, I have access to jQuery - maybe there is some way to detect the browser

我目前正在使用它,它适用于IE和Firefox但不适用于Chrome

I am currently using this and it works for IE and Firefox but not chrome

if (window.sidebar) { // Mozilla Firefox
    window.sidebar.addPanel(name, url, "");
}
else if (window.external) { // IE
    window.external.AddFavorite(url, name);
}
else if (window.opera && window.print) {
    window.external.AddFavorite(url, name);
}
else {
    alert('not supported');
}


推荐答案

对不起, - 浏览器方式来做到这一点。您的FF示例也被破坏:它不会创建一个常规的书签,而是一个要在侧边栏中打开的书签集。您必须使用书签 - 服务创建实际的书签,但此将由于安全限制而失败。

Sorry, but there's no cross-browser way to do this. Your FF example is broken as well: It won't create a regular bookmark, but a bookmark set to be opened in the sidebar. You'd have to use the bookmark-service to create an actual bookmark, but this'll fail due to security restrictions.

这篇关于从JavaScript添加到浏览器收藏/书签,但对于所有浏览器(我的Chrome不工作)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆