Protect Against Invaders by SPAM-Proofing Your Website - How to Use the JavaScript Method
The following are examples of JavaScript that you can use to make your email address appear different in the code but still perform the same function as if it were regularly coded in HTML (ie: mailto:support@example.com). To use these examples, just copy and paste the code into your HTML document and replace the required field(s) with your email address.
1. Basic Email Script
<script language=JavaScript>
<!--
document.write("support" + "@" + "example.com");
//-->
</script>
Result: support@example.com
2. Basic Mailto: Email Script with Link Text
<script language=JavaScript>
<!--
var username = "support";
var hostname = "example.com";
var linktext = username + "@" + hostname;
document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + linktext + "</a>");
//-->
</script>
Result: support@example.com
3. Inline JavaScript
<a href="#" onclick="JavaScript:window.location='mailto:'+'support'+'@'+'example'+'.com'">Link Text</a>
Result: Link Text
The three scripts options above should give you some flexibility in how you choose to use these on your website. Remember to insert your own email address into the fields where the support@example.com email address is located.
Problems Associated with JavaScript
There doesn't appear to be many problems with using the above scripts in the HTML code of your documents. The biggest issue may be incorrectly coding the scripts or issues with older browsers that do not support JavaScript. One last issue that may see its day in history is email harvester programmers being able to find email addresses among the JavaScript code. While this may be a reality sooner than we expect, for the most part JavaScript should be SPAM-proof enough to block most malicious SPAM bots.
No comments:
Post a Comment