is this possible to bookmark a page with html button?

Jasjeet Singh picture Jasjeet Singh · Jul 31, 2017 · Viewed 13.8k times · Source

is this possible to bookmark a page with html button?

<button>Bookmark This page</button>

this code instruct you to how to bookmark a page in chrome. but i want to open a dialog box where we press finished in google chrome.

Answer

Dhaarani picture Dhaarani · Jul 31, 2017

$(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>