Forum Moderators: open
You could try to do it using a cgi script like formmail or an asp or php server side script. Check your hosting information, it might already be included.
If you still want to go the js way check out resources like javascript.internet.com, they have loads of cool scripts.
JavaScript can call an email client, though, of course, the client's browser must have the interpreter active. The following script demonstrates a JavaScript function to compose and send the email as well as a backup of a mailto action. Note that a mailto address in a page can be harvested by spambots.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function sendMail(_frm){
var eml="you@youraddress.com";
var bod="&body="+_frm.selOne.value+" ¦¦ "+_frm.txtOne.value;
var subj="?subject=Whatever you want";
document.location="mailto:"+eml+subj+bod;
}
</script>
</head>
<body>
<form action="mailto:you@youraddress.com" enctype="text/plain"
method="POST" onsubmit="sendMail(this);return false;">
<select name="selOne">
<option value="Dog">Dog</option>
<option value="Cat">Cat</option>
</select>
<textarea name="txtOne"></textarea>
<input type="submit" value="Submit" />
</form>
</body>
</html>
You can submit forms to the server without invoking the email client. You would need server-side scripts to handle the forms, for instance in PHP. Forms and email are the main ways of sending information from the client.
Is it possible to do it in jsp to send the page to an email address? I have some knowledge of jsp but not of sending page to email.
Writing such a script from scratch would be a considerable effort unless you already know perl or php, etc. You might be able to find something similar and adapt it, but this would still entail some effort.
Browsers are simply not designed to perform this function.
Kaled.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function getInH(){
var bod=document.getElementById("pgBod").innerHTML;
alert(bod);
}
</script>
</head>
<body id="pgBod" onload="getInH();">
<p>Stuff to see</p>
</body>
</html>