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>
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With