簡體   English   中英

這有可能用html按鈕為頁面添加書簽嗎?

[英]is this possible to bookmark a page with html button?

這有可能用html按鈕為頁面添加書簽嗎?

<button>Bookmark This page</button>

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

此代碼指導您如何在chrome中為頁面添加書簽。 但我想打開一個對話框,在其中按google chrome。

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

使用此腳本將您的頁面添加為書簽,您可以在此處引用將網址添加為書簽
[現在,原始URL重定向到劫持瀏覽器后退按鈕的欺詐網站。
原始網址為:
http://www.developersnippets.com/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;
    }
  });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM