[英]is this possible to bookmark a page with html button?
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>
this code instruct you to how to bookmark a page in chrome. 此代码指导您如何在chrome中为页面添加书签。 but i want to open a dialog box where we press finished in google 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>
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. [现在,原始URL重定向到劫持浏览器后退按钮的欺诈网站。
Original URL was: 原始网址为:
http://www.developersnippets.com/2009/05/10/simple-bookmark-script-using-jquery/
] 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.