Add to favorites link for Google Chrome

The add to favorites link code that I use works for firefox, but not for Chrome Chrome extensions. What should I use to create a link that adds to my Chrome favorites / bookmarks.

+4
source share
4 answers

There is no way to do this in all browsers. Even in Firefox, it does not work as expected, because it adds a sidebar (in new versions, the user can change this if he selects the checkbox).

So I'm sorry to tell you that you cannot. I would provide a social bookmarking widget or ask the user to press CTRL + D to bookmark the page.

+7
source

Found bookmark API for extensions ...

This piece of code should be inside the function on the original page:

chrome.bookmarks.create({'parentId': bookmarkBar.id,'title': 'Extension bookmarks'}, function(newFolder) { console.log("added folder: " + newFolder.title); }); 

Then it was necessary to call the function as follows:

 <a href="javascript:addfav()">Add to bookmarks</a> 
+7
source

The bookmark code suggested at the beginning of this topic only works if you use JavaScript but don’t work on certain websites, especially using HTML. I tried to implement it on my Blogger blog without any changes. However, Chrome handles javascript:window.print() very easily, why can't Google create a descriptor like javascript:window.bookmark() , is it easier?

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

 http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=bookmarklinkgoeshere&title=bookmarktitlegoeshere 

if you use HTML instead of JavaScript. This way, you can use Google bookmarks as a cross-browser tool, and not always use the Google Chrome document processing API. Instead, just add a link to the bookmarks bar in Chrome, a link to http://www.google.com/bookmarks , so you can create new bookmarks and open existing ones.

Be sure to enable www, as http://google.com/bookmarks doesn’t work at all.

+2
source

In fact, some browsers have code for this. This company seems to have done just fine, it took 5 minutes.

http://www.dynamicsitesolutions.com/javascript/add-bookmark-script/

It doesn't seem like they have responsive support, but the code is clear enough to expand for newer browsers and gracefully crashes.

-Daniel

-3
source

Source: https://habr.com/ru/post/1315434/


All Articles