Stanford University Stanford Hospital & Clinics Lucile Packard Children's Hospital VA Palo Alto Santa Clara Valley Medical
Stanford School of Medicine Web & New Media Services
This Site Only
All School of Medicine Sites
IRT Logo

Web Clips, Tips, Tricks

>
>
>
>
>
>
>
>
>
Web & New Media Services
>
>
>
v
 
>
>
>
>
>
>
 

Anti-spam Mailto JavaScript

The following examples and code can be used to offer some protection from address-gathering spam robots when you need to put an email address on a Web page. You will need access to the page's code. Copy the appropriate item and modify the code to replace 'ja' + 'ne' with 'firsthalfofname' + 'otherhalfofname' It also shouldn't be too hard to figure out how to modify one of these examples for another email domain.

Live example

JavaScript code

Jane @ Stanford:

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'stan' + 'ford.edu')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ Med:

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'med.' + 'stan' + 'ford.edu')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ MedCenter

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'medcenter' + '.stanford' + '.edu')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ Stanfordhospital.org

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'stanford' + 'hospital' + '.org')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ CMGM:

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'cmgm.' + 'stan' + 'ford.edu')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ Yahoo:

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'ya' + 'hoo' + '.com')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Jane @ Hotmail:

<script TYPE="text/javascript">
<!--
emailE=('ja' + 'ne' + '@' + 'hot' + 'mail' + '.com')
document.write('<a href="mailto:' + emailE + '">' + emailE + '</a>')
//-->
</script>

Note: For individual contacts, you can always provide a link to the person's Stanford.Who listing instead of providing the address.