Skip to content

Instantly share code, notes, and snippets.

@perymimon
Last active March 15, 2019 12:57
Show Gist options
  • Save perymimon/664df356b71916e7456a to your computer and use it in GitHub Desktop.
Save perymimon/664df356b71916e7456a to your computer and use it in GitHub Desktop.
work in Firefox, IE, Opera . not work on IE when protocol is 'javascript'
function addToBookmark(title,href){
if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
window.sidebar.addPanel(title,href,'');
} else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
window.external.AddFavorite(href, title);
} else if(window.opera && window.print) { // Opera Hotlist
this.title = title;
return true;
} else { // webkit - safari/chrome
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment