Last active
March 15, 2019 12:57
-
-
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'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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