Mailing Pages

Sometimes you’ll be surfing along, and you’ll find a page that’s so useful you need to share it with your co-workers, or maybe it’s so funny you need to share it with your best friend. This bookmarklet, Script 17.14, takes the page you’re on, plus any highlighted text, and uses it to create a new outgoing email

To mail a Web page:

  • location.href='mailto:?SUBJECT='+document.title+'&BODY='+escape(location.href)+' \r'+window.getSelection();

    If you’ve ever put a mailto link on a Web page, you should recognize this syntax. All this does is act just as if you’ve clicked on a <a href='mailto:'></a> link. The subject of the email is set to the title of the current document, and the body of the email is set to the URL of the page plus any ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.