spacer
Yehuda Shiran August 22, 2000
Mailing a Web Page
Tips: August 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

You send a mail message with the mailto: URL. Open your mail application and type mailto: in your browser's Address field. A new message form will open and wait for your input. You can prefill the form by providing the subject and body parameters of the mailto: URL. You provide a parameter in the URL by prepending the parameter name with a question mark (?), followed by an equal sign (=). For example:

....?subject= ....

Notice that there should not be any spaces between the parameter name and the equal sign. To send the current page's URL in a mail message, we just assemble the current location.href in the body part:

&body= ...location.href...

To make the message even more attractive, we decorate both its subject and its body with the current page's title, document.title. The following mailpage() function assembles the mail message and posts it to the browser's Address field:

<script language="javascript">
function mailpage()
{
  mail_str = "mailto:?subject= Doc JavaScript: " + document.title;
  mail_str += "&body= I recommend Doc JavaScript's (docjavascript.com) tip -- " + document.title;
  mail_str += ". You should check this out at, " + location.href; 
  location.href = mail_str;
}
</script>

Somewhere on the page you need to provide a link that calls the above function, like this:

<A HREF = "javascript:mailpage()">E-mail This Page</A> E-mail This Page

This tip has been contributed by Paul Hansford.


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger