PDA

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



dummy44
Dec 16th, 2003, 08: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.

requestcode
Dec 16th, 2003, 08: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.

glenngv
Dec 17th, 2003, 02: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;
}
</script>
...
<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.