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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint