跨浏览器书签/添加到收藏夹 JavaScript
是否有使用 JavaScript 的跨浏览器书签/添加到收藏夹。
搜索了一些列表,但没有一个有效。你能推荐一下吗?
Is there any cross-browser bookmark/add to favorites using JavaScript.
Searched for some list but none is working. Can you please suggest any?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
jQuery 版本
JavaScript(根据我在某人网站上找到的脚本修改 - 我只是无法再次找到该网站,所以我无法给予该人信用):
HTML:
IE 将显示错误,如果您不会在服务器上运行它(当将其作为
file://...
查看时,它不允许通过 JavaScript 添加 JavaScript 书签)。jQuery Version
JavaScript (modified from a script I found on someone's site - I just can't find the site again, so I can't give the person credit):
HTML:
IE will show an error if you don't run it off a server (it doesn't allow JavaScript bookmarks via JavaScript when viewing it as a
file://...
).我用过这个&在 IE、FF、Netscape 中运行良好。
Chrome、Opera 和 safari 不支持!
I used this & works great in IE, FF, Netscape.
Chrome, Opera and safari do not support it!
使用 ShareThis 或 添加这个?它们具有相似的功能,因此很可能它们已经解决了问题。
AddThis 的代码有一个巨大的 if/else 浏览器版本分支,用于保存收藏夹,但大多数分支最终都会提示用户自己手动添加收藏夹,所以我认为不存在这样的纯 JavaScript 实现。
否则,如果您只需要支持 IE 和 Firefox,则有 IE 的 window.externalAddFavorite( ) 和 Mozilla 的 window.sidebar.addPanel( ) .
How about using a drop-in solution like ShareThis or AddThis? They have similar functionality, so it's quite possible they already solved the problem.
AddThis's code has a huge if/else browser version fork for saving favorites, though, with most branches ending in prompting the user to manually add the favorite themselves, so I am thinking that no such pure JavaScript implementation exists.
Otherwise, if you only need to support IE and Firefox, you have IE's window.externalAddFavorite( ) and Mozilla's window.sidebar.addPanel( ).