Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a "Bookmark this page" button?

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>
like image 474
Sunfloro Avatar asked Feb 19 '19 05:02

Sunfloro


People also ask

How do I bookmark a page in HTML?

To create a bookmark link in HTML, you need to create a bookmark using the <a> tag name attribute. Now, add a link to the bookmark. Bookmarks are also known as named anchors. This is quite useful to take readers to a specific section of the web page.


1 Answers

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.

like image 180
Ouroborus Avatar answered Oct 02 '22 07:10

Ouroborus