Cross-browser bookmark/add to favorites JavaScript
jQuery Version
JavaScript (modified from a script I found on someone's site - I just can't find the site again, so I can't give the person credit):
$(document).ready(function() {
$("#bookmarkme").click(function() {
if (window.sidebar) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(location.href,document.title,"");
} else if(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;
}
});
});
HTML:<a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a>
IE will show an error if you don't run it off a server (it doesn't allow JavaScript bookmarks via JavaScript when viewing it as a file://...
). Add to browser favorites/bookmarks from JavaScript but for all browsers (mine doesn't work in Chrome)?
Sorry, but there's no cross-browser way to do this. Your FF example is broken as well: It won't create a regular bookmark, but a bookmark set to be opened in the sidebar. You'd have to use the bookmark-service to create an actual bookmark, but this'll fail due to security restrictions.
How to create a Bookmark this page button?
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.
Make browser bookmark my link?
From Vaadin you can execute any javascript code you wish.
In the book of vaadin there is a example on how to acomplish it.
In short you can execute any JS code with this method:
// Shorthand
JavaScript.getCurrent().execute("alert('Hello')");
Of course you will need to find the correct JS code to bookmark your page.If you wish to bookmark a specific application state/view, then you can use the Navigator for this. (It basically adds a #SomeState to your URL which you can the later come back)
How do I add an Add to Favorites button or link on my website?
jQuery Version
$(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>
Javascript bookmark button
Yep - without giving you the best way of doing it - here's a horrible DHTML solution:
http://www.dynamicdrive.com/dynamicindex9/addbook.htm
Related Topics
How to Convert a Firestore Date/Timestamp to a Js Date()
Get Width Height of Remote Image from Url
How to Send Authorization Header with Axios
JavaScript String and Number Conversion
Obtain Smallest Value from Array in JavaScript
Wait Till a Function with Animations Is Finished Until Running Another Function
Select a Complete Table with JavaScript (To Be Copied to Clipboard)
Do We Need Semicolon at the End
Angularjs - Cancel Route Change Event
Angular Ui-Router $Urlrouterprovider .When Not Working When I Click <A Ui-Sref="...">
Create a <Ul> and Fill It Based on a Passed Array
Why Firefox Says That Window.Event Is Undefined? (Call Function with Added Event Listener)
Objects Are Not Valid as a React Child (Found: [Object Promise])