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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management
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:

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags