开发者

Add to favourites link for Google Chrome

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


Found the Bookmarks API for extensions...

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>


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).

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.


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?

There is another way. Since Google Bookmarks is available, try using

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.

Make sure to include the www since http://google.com/bookmarks doesn't work at all.


Use a sharing URL. Here are your available parameters:

  • bkmk : Holds your URL.
  • title : Holds your title.
  • annotation : Holds your text.
  • labels: Holds your keywords or hashtags.

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.

Add to favourites link for Google Chrome

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜