通用添加到书签脚本?
有谁知道我可以使用一个脚本在单击多个浏览器的链接时自动将站点添加到收藏夹?至少 Firefox、IE、Chrome 都不错。
如果没有,有没有一种方法可以通过 Javascript 模拟 ctrl+D,因为我知道击键会在大多数浏览器中将站点添加到书签?
Does anyone know of a script that I can use to automatically add a site to favourites upon clicking of a link for multiple browsers? Atleast Firefox, IE, Chrome would be good.
If not, is there a way I can simulate ctrl+D through Javascript as I know that keystroke adds a site to bookmark in most browsers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
用于添加书签的通用脚本并不存在,因为并非所有浏览器都公开用于创建书签的 API。一般来说,只有 IE 公开了一个直接的 API。 Opera 和 Firefox 都提供了将网站添加到书签的可能性,这些书签将在侧边栏中打开,这是一个巨大的差异。 Safari 和 Chrome 也不会公开任何用于此任务的 API。
有关此主题的更多信息
A universal script for adding to bookmarks doesn't exists, because not all browsers expose an API for creating bookmarks. Generally, only IE exposes a direct API for this. Both Opera and Firefox offer a possibility to add a site to bookmarks that will be opened in the sidebar and that is a huge difference. Safari and Chrome also don't expose any API for this task.
Some more info on this topic
我使用一个小脚本尝试使用最流行的窗口方法添加书签,直到全部失败。然后它只是提示用户手动添加书签...
就像其他人所说(上面),某些浏览器禁止脚本激活的书签,并且出于安全考虑,他们只希望用户添加书签。
它并不完美,但它很简单并且运行良好。
I use a small script to attempt adding a bookmark using the most popular window methods, until all have failed. Then it just prompts the user to manually add their bookmark...
Like others have said (above) some browsers prohibit script-activated bookmarking, and because of security they want only users to add bookmarks.
It is not perfect, but it is simple and works well.
如果您正在使用该 jquery 插件,则可以查看该插件;如果您想使用自己的插件,则可以查看其源代码。尽管他在兼容性方面提到 Safari 和 Chrome 并未在其 API 中公开此功能。
http://www.dummwiam.com/jFav
You can check out this jquery plugin if you are using that or just look at their source if you want to use your own. Though he mentions on his compatibility that Safari and Chrome do not expose this functionality in their API.
http://www.dummwiam.com/jFav
请参阅数字灵感。
javascript 书签
的第一个 Google 结果。See digitalinspiration.
1st Google result for
javascript bookmark
.在 Internet Explorer 中,它适用于:
window.external.AddFavorite(document.location,document.title);
在 Firefox 和 Opera 中:
我还没有找到 safari / chrome 的解决方案。
In internet explorer it works with:
window.external.AddFavorite(document.location,document.title);
in firefox and in opera with:
I haven't found a solution for safari / chrome yet.