This post is how to create add to bookmark link for your blog or site
using this link in your site there may be a small increament in your blog with returning visitor.
initialy i found it on prestashop .
you can add a quick “Bookmark this page” link in all your pages so that user can bookmark their favorite pages or articles.
this script supported by IE, Mozilla Firefox and Opera Browsers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
function addBookmark(url, title){ if (!url) {url = window.location} if (!title) {title = document.title} var browser=navigator.userAgent.toLowerCase(); if (window.sidebar) { // 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 { // 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) { // Konqueror alert(‘Please press CTRL+B to bookmark this page.’); } else if (browser.indexOf(‘webkit’)!=-1){ // 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.’) } } |
You can call it from html by button or a hyperlink
here i m calling it from a button
1 2 |
<input type=“button” value=“bookmark me” onclick=“addBookmark(‘https://buffernow.com’,’buffer now’);”/> |
And here is the full html source
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<html> <head> <script type=“text/javascript”> function addBookmark(url, title){ if (!url) {url = window.location} if (!title) {title = document.title} var browser=navigator.userAgent.toLowerCase(); if (window.sidebar) { // 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 { // 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) { // Konqueror alert(‘Please press CTRL+B to bookmark this page.’); } else if (browser.indexOf(‘webkit’)!=-1){ // 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.’) } } </script> </head> <body> <input type=“button” value=“book mark me” onclick=“addBookmark(‘https://buffernow.com’, ‘buffer Now’);”/> </body> </html> |
if browsder is chrome and safari or browser javascript is disable the this code will not works.
due to security aspects chrome and safari does not let you add bookmarks via Javascript