Skip to content

Instantly share code, notes, and snippets.

@rondevera
Created June 26, 2009 03:58
Show Gist options
  • Save rondevera/136298 to your computer and use it in GitHub Desktop.
Save rondevera/136298 to your computer and use it in GitHub Desktop.
Gmail bookmarklet: For quickly e-mailing the current page's URL (and the selected text, if any) via Gmail.
/*
Gmail bookmarklet
rondevera.com
For quickly e-mailing the current page's URL (and the selected text, if any)
via Gmail.
Usage:
- Create a new item in your bookmark bar with "Gmail" (or just "Gm") as the
name, and the code below as the location.
- Activate it (by click or keyboard shortcut), and a small Compose window
opens with the page's title and URL, and a couple of line breaks for you to
add a note. If you selected any text, it'll automatically be added with
quotation marks.
- Tested by daily use in Safari, but not perfect. Might be too long
for less capable browsers (you know which one -- oh snap!).
Credit:
- Adapted from somewhere, though I can't remember the source. Please let me
know if you do!
- MIT license
*/
javascript:(function(){popw='';Q='';x=document;y=window;if(x.selection)%20{Q=x.selection.createRange().text;}%20else%20if%20(y.getSelection)%20{Q=y.getSelection();}%20else%20if%20(x.getSelection)%20{Q=x.getSelection();}popw%20=%20y.open('https://mail.google.com/mail?ui=2&view=cm&tf=0&to=&su='%20+%20escape(document.title.replace(/^\s+|\s+$/g,''))%20+%20'&body='%20+%20escape(location.href)+%20escape('\n\n'+(Q&&Q!=''?'"'+Q+'"':''))%20,'gmailForm','scrollbars=yes,width=500,height=400,top=50,left=50,status=no,resizable=yes');if%20(!document.all)%20T%20=%20setTimeout(function(){popw.focus()},50);void(0);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment