javascript
JavaScript is a scripting language, it is client side based (i.e. it runs on the visitors browser) as opposed to server based (like Perl) which runs on your server.
Remember JavaScript ISN'T Java while they have similar names they are completely different.
JavaScript can be used for many things including form validation, real-time changes to web pages and like the example below, for automatically sending email.
The following example generates a button on the page, similar to the newsletter sign-up page on this site.
When the button is clicked the script automatically simulates a mailto link being clicked on, reads the visitors default email address and puts the message in their outbox.
If their mail program is set up to send mail immediately the message will be sent straight away.
JavaScript Code:
<script language="javascript"> <!-- Hide from old browsers function scramble(){ var p1,p2,p3,p4,p5,p6 p1='action="mai' p2='first_part_of_your_email_address' p3='">' p1+='lto:' p2+='@' p5='</a>' p6='first_part_of_your_email_address' p2+='youremaildomain.com?your subject message ENCTYPE="text/plain"' p4=p6
document.write("<form NAME=\"signup\" METHOD=\"post\""+p1+p2+"><input type=\"submit\" name=\"submit\" value=\"Click here to sign-up for our free newsletter\"><\/form>")
}
scramble()
//--> </script>
All you need to do is enter your own details, if your email address is john.doe@abcxyz.com then p6 would have the value john.doe, p2 would be abcxyz.com?your subject message ENCTYPE="text/plain
p4 holds the same details as p6
That's it! Place the code on your page at the point you want the button to appear.
If you want to learn more about JavaScript check out this excellent resource, JavaScript for the World Wide Web. It's a great book full of tips, code and examples.
There's an accompanying web site where you can download the code examples from which makes thinks a lot easier!
|