How to create a "Bookmark this page" button?
11,285
Once upon a time, this could be done. But unscrupulous sites would abuse the capability, forcibly bookmarking sites the user didn't want bookmarked. Now it is no longer possible for pages to add bookmarks on behalf of the user.
Author by
Sunfloro
Updated on July 10, 2022Comments
-
Sunfloro almost 2 years
I setting up a website and would like to add a simple button to allow a visitor add my page to their bookmarks/favorites. There is a way to do this using javascript? And there is a cross-browser solution?
All of previous answers in Stack Overflow doesn't work anymore, tried all of most recent and some of really old of them, but had no success. This is not a duplicate question.
I tried a lot of solutions, but the last one was:
$(function() { $('#bookmarkme').click(function() { if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark window.sidebar.addPanel(document.title, window.location.href, ''); } else if (window.external && ('AddFavorite' in window.external)) { // IE Favorite window.external.AddFavorite(location.href, document.title); } else if (window.opera && window.print) { // Opera Hotlist this.title = document.title; return true; } else { // webkit - safari/chrome alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.'); } }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a>