Html 添加到 Google Chrome 的收藏夹链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3230499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add to favourites link for Google Chrome
提问by David
The "add to favorites" link code that I use, works for firefox but not for Google chrome extensions. What should i use to create a link that adds to Chrome favorites/bookmarks
我使用的“添加到收藏夹”链接代码适用于 Firefox,但不适用于 Google chrome 扩展。我应该使用什么来创建添加到 Chrome 收藏夹/书签的链接
回答by 2ndkauboy
There is no way to do it in all browsers. Even in Firefox it doesn't work as expected as it adds a sidebar (on newer versions the user can change that, if he finds the checkbox).
没有办法在所有浏览器中做到这一点。即使在 Firefox 中,它也不能按预期工作,因为它添加了一个侧边栏(在较新的版本中,如果用户找到了复选框,则可以更改它)。
So I am sorry to tell you that you can't. I would provide a social bookmarks widget or ask the user to press CTRL + D to bookmark a page.
所以我很抱歉地告诉你,你不能。我会提供一个社交书签小部件或要求用户按 CTRL + D 为页面添加书签。
回答by David
Found the Bookmarks APIfor extensions...
找到了用于扩展的书签 API...
This piece of code needed to be inside a function in the background page:
这段代码需要在后台页面的一个函数中:
chrome.bookmarks.create({'parentId': bookmarkBar.id,'title': 'Extension bookmarks'},
function(newFolder) {
console.log("added folder: " + newFolder.title);
});
Then had to call the function like this:
然后不得不像这样调用函数:
<a href="javascript:addfav()">Add to bookmarks</a>
回答by warrenwoodhouse
The bookmark code you suggested at the top of this topic only works if you're using JavaScript but doesn't work on certain websites, especially those using HTML. I've tried to implement it into my Blogger blog with no succession. However, Chrome handles javascript:window.print()
very easily, why can't Google just create a handle like javascript:window.bookmark()
, wouldn't that not be so much easier?
您在本主题顶部建议的书签代码仅在您使用 JavaScript 时有效,但不适用于某些网站,尤其是那些使用 HTML 的网站。我已经尝试将它实施到我的 Blogger 博客中,但没有继任。但是,Chrome 处理起来javascript:window.print()
很容易,为什么 Google 不能只创建一个像 的句柄javascript:window.bookmark()
,那不是更容易吗?
There is another way. Since Google Bookmarksis available, try using
还有另一种方法。由于Google 书签可用,请尝试使用
http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=bookmarklinkgoeshere&title=bookmarktitlegoeshere
if you're using HTML instead of JavaScript. This way, you can use Google Bookmarks as a cross-browser tool instead of relying on Google Chrome handle API all the time. Instead, just add a link on the Bookmarks Bar on Chrome, the link to http://www.google.com/bookmarks
so you can create new bookmarks and open existing ones.
如果您使用 HTML 而不是 JavaScript。这样,您就可以将 Google Bookmarks 用作跨浏览器工具,而不必一直依赖 Google Chrome 句柄 API。相反,只需在 Chrome 的书签栏上添加一个链接,该链接http://www.google.com/bookmarks
即可创建新书签并打开现有书签。
Make sure to include the www since http://google.com/bookmarks
doesn't work at all.
确保包含 www,因为http://google.com/bookmarks
它根本不起作用。
回答by HoldOffHunger
Use a sharing URL. Here are your available parameters:
使用共享 URL。以下是您的可用参数:
bkmk
: Holds your URL.title
: Holds your title.annotation
: Holds your text.labels
: Holds your keywords or hashtags.
bkmk
: 保存您的网址。title
: 持有你的头衔。annotation
: 保存您的文本。labels
:保存您的关键字或主题标签。
URL:
网址:
https://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}&annotation={text}&labels={hash_tags}
If you want to stay in contact with a project that regularly keeps up to date on these formats and APIs, then check us out! Github: Social Share URLs.
如果您想与定期更新这些格式和 API 的项目保持联系,请查看我们! Github:社交分享 URL。