Add to favourites link for Google Chrome

32,632

Solution 1

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.

Solution 2

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>

Solution 3

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.

Share:
32,632
David
Author by

David

Student and Google Chrome extension developer

Updated on July 09, 2022

Comments

  • David
    David almost 2 years

    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

  • Ed Bishop
    Ed Bishop over 11 years
    You can do it in most browsers though and the question was how to add it to Chrome favourites.
  • trainoasis
    trainoasis over 8 years
    Is this possible in 2015 perhaps?
  • warrenwoodhouse
    warrenwoodhouse almost 8 years
    Thanks Xan. :D It's funny, the fact that javascript:window.history() and javascript:window.print() both work in the PS3 Internet Browser, PS4 Internet Browser, Google Chrome and other browsers but Google couldn't be bothered to create a bookmark handler! Seriously. Google Bookmarks works in the Internet Browser of the PlayStation 3 & PlayStation 4 consoles as well as through the Google Toolbar (which is for other browsers instead of Chrome) and Google Bookmarks is still really useful on Google Chrome, which is why I recommend it.
  • warrenwoodhouse
    warrenwoodhouse almost 8 years
    Here's the code as it would play out: <a target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&output=po‌​pup&bkmk=http://warr‌​enwoodhouse.webs.com‌​/&title=Warren%20Woo‌​dhouse:%20T-Codes" alt="Add Bookmark To Your Google Bookmarks" title="Add Bookmark To Your Google Bookmarks"></a> - that code is what it would look like, with the target opening a new tab. Once you save a link, it redirects to the homepage of Google Bookmarks and lists all your bookmarked items including saved links that you've Starred during Google Search.