最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - is this possible to bookmark a page with html button? - Stack Overflow

programmeradmin3浏览0评论

is this possible to bookmark a page with html button?

<button>Bookmark This page</button>

function onclickfunction(){
  alert('Press Ctrl + D to bookmark this page');
}
<script src=".1.1/jquery.min.js"></script>
<button onclick="onclickfunction()">Bookmark this page</button>

is this possible to bookmark a page with html button?

<button>Bookmark This page</button>

function onclickfunction(){
  alert('Press Ctrl + D to bookmark this page');
}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button onclick="onclickfunction()">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.

Share Improve this question asked Jul 31, 2017 at 12:13 Jasjeet SinghJasjeet Singh 3321 gold badge7 silver badges19 bronze badges 1
  • Now it is no longer possible for pages to add bookmarks on behalf of the user. – Vincente Commented Feb 2, 2022 at 15:29
Add a ment  | 

2 Answers 2

Reset to default 5

$(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./ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a>

Use this script to bookmark your page, you can reference here bookmark a url
[Original URL now redirects to a scam website that hijacks the browser's back button.
Original URL was:
http://www.developersnippets./2009/05/10/simple-bookmark-script-using-jquery/]

$("button").click(function(e){
    e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
    var bookmarkUrl = "your_bookmark_url";
    var bookmarkTitle = "your_bookmark_title";

    if (window.sidebar) { // For Mozilla Firefox Bookmark
        window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
    } else if( window.external || document.all) { // For IE Favorite
        window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
    } else { // for other browsers which does not support
         alert('Your browser does not support this bookmark action');
         return false;
    }
  });
发布评论

评论列表(0)

  1. 暂无评论