22i design - web design Farnborough

Thursday, March 11, 2010



This page uses Valid CSS
Valid HTML 4.01!
For what it's worth, 22i design is a member of the UKWDA
Get FireFox - The Browser ReLoaded



22i DESiGN » WEB DESiGN TiPS » ANTI-SPAM » USING JAVASCRIPT

Anti-Spam using JavaScript

Using JavaScript to present an email address on a webpage is one small way of potentially helping to slow down the proliferation of spam email. This method does not present a straightforward email address in the code of the webpage, but uses the javascript to build and display an email address from seperate elements when the page is displayed in the browser window.

As with all anti-spam tips, you may wish to use this in conjunction with other anti-spam methods to create numerous "hurdles" to guard against unwanted email.

OK. Between the <head></head> tags in your webpage paste the following piece of javascript

<script type="text/javascript" language="JavaScript">
var user;
var domain;
var suffix;
function antispam(user, domain, suffix){
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + user + '@' + domain + '.' + suffix + '<\/a>');}
</script>

What this script does is set up the variables, user, domain and suffix. The actual function is called antispam and when it is called it writes an email address using the variables you define in the call.

Here is the call...

<script type="text/javascript" language="JavaScript">
antispam("info", "yourdomainname", "com");
</script>

Place the call in the page where the email adress would normally be.

Which would display a live link to the email address info@yourdomainname.com

If you wish to display multiple email addresses on a page, just use a new call for each email address and re-define the variables accordingly.