View Full Version : Email link which send the current web page

Dec 16th, 2003, 09:19 PM
I have search high and low but can't find any code examples...

Does anyone have some script lying around which creates a link to email the contents of the current webpage.

I was hoping that it would just open a compose window in the users email client, display the html page in the message body and rely on them entering the email address as per usual.

Dec 16th, 2003, 09:57 PM
You can't use JavaScript to display a document in an email. You will have to use a Server Side language such as PHP, Perl or ASP to do that. You could though use JavaScript to place a link in the body of the email that they could click on to go to the page.

Dec 17th, 2003, 03:28 AM
<script type="text/javascript">
function doMail(){
location.href="mailto:?subject=" + escape("Great site!") + "&body=" + escape("This is a great site: " + location.href);
return false;
<a href="#" onclick="return doMail()">Send as link</a>

But using mailto is unreliable and not all machines have default mail client installed (or set up). Use server-side language as requestcode suggested.