Skip to content

Instantly share code, notes, and snippets.

@shane-reaume
Created April 10, 2013 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shane-reaume/5357378 to your computer and use it in GitHub Desktop.
Save shane-reaume/5357378 to your computer and use it in GitHub Desktop.
Bookmark This Page
function bookmarkPage(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('TO BOOKMARK OUR PAGE:\n\n Press CTRL+D (or Command+D for macs)\n after closing this box');
}
}
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('TO BOOKMARK OUR PAGE:\n\n Press CTRL+B (or Command+D for macs).\n\n If you have a mobile device,\nselect menu for device to see bookmark options.');
}
else {
alert('Your browser cannot add bookmarks using this link. Please add this link manually.')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment