During a visitor visit a web page, if he/she like the page he/she do bookmarking for future reference. In such case as a programmer you require a bookmarking script to implement in your app. Look at the below demo app, here I implemented a JavaScript bookmark function. This function is cross browser compatible. By simply copy paste the below code you can easily add bookmarking functionality to your HTML page.
The logic I implemented here is very simple. By using JavaScript indexOf() method I am checking which kind of browser client is using. Depending upon the browser I am displaying a message about the shortcut key to bookmark in that browser.
JavaScript Bookmark Function
function bookmarkPage(url, title) { if (!url) { url = window.location } if (!title) { title = document.title } var browser = navigator.userAgent.toLowerCase(); if (window.sidebar) { // for Mozilla, Firefox & Netscape window.sidebar.addPanel(title, url, ""); } else if (window.external) { // IE or chrome if (browser.indexOf('chrome') == -1) { // ie window.external.AddFavorite(url, title); } else { // for Google Chrome alert('Please Press CTRL+D (or Command+D for macs) to bookmark this page'); } } else if (window.opera && window.print) { // Opera - automatically adds to sidebar if rel=sidebar in the tag return true; } else if (browser.indexOf('konqueror') != -1) { // for Konqueror alert('Please press CTRL+B to bookmark this page.'); } else if (browser.indexOf('webkit') != -1) { // for Safari alert('Please press CTRL+B (or Command+D for macs) to bookmark this page.'); } else { alert('Your browser cannot add bookmarks using this link. Please add this link manually.') } }