Skip to content

Instantly share code, notes, and snippets.

@hrs113355
Last active August 29, 2015 14:11
Show Gist options
  • Save hrs113355/5859ff5ad283ad7cfcf0 to your computer and use it in GitHub Desktop.
Save hrs113355/5859ff5ad283ad7cfcf0 to your computer and use it in GitHub Desktop.
bookmark
<a id="bookmark" href="#" rel="sidebar">bookmark</a>
$('a#bookmark').click (e) ->
bookmarkURL = location.href
bookmarkTitle = document.title
try
if window.sidebar? and window.sidebar.addPanel? # FireFox <= 23
window.sidebar.addPanel(bookmarkTitle, bookmarkURL, "")
else if window.opera? or window.sidebar? # Opera & FireFox > 23
$('a#bookmark').attr('href',bookmarkURL)
$('a#bookmark').attr('title',bookmarkTitle)
$('a#bookmark').attr('rel','sidebar')
else if window.external or document.all # IE
window.external.AddFavorite(bookmarkURL, bookmarkTitle)
catch err # Webkit and others
alert 'edit ' + (if navigator.userAgent.toLowerCase().indexOf('mac') != - 1 then 'Command/Cmd' else 'CTRL') + ' + D to bookmark'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment