David
David

Reputation: 13999

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

Upvotes: 7

Views: 34213

Answers (4)

HoldOffHunger
HoldOffHunger

Reputation: 20891

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.

Social Share URLs

Upvotes: 0

David
David

Reputation: 13999

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>

Upvotes: 8

warrenwoodhouse
warrenwoodhouse

Reputation: 63

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.

Upvotes: 4

2ndkauboy
2ndkauboy

Reputation: 9387

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.

Upvotes: 7

Related Questions