Obscuring email addresses from spammers

Here’s how to use an image and a .js script to disguise your email address from spam bot email collectors. This method splits the email address server side.

(1) Make an image of the email address you wish to use in .jpg, .gif or .png form.

(2) Creat a .js script as follows*:

var sb_domain = "yourdomain.com"
var sb_user = "whatever"
var sb_recipient = sb_user + "@" + sb_domain
var image = "<img alt='Contact Me' xsrc='images/e.png' height='11' width='166' style='margin-top:2px;border:0' />"
var sb_url = "mailto:" + sb_recipient
document.write(image.link(sb_url));

If you want to include a subject, use this code:

var sb_domain = "yourdomain.com"
var sb_user = "whatever"
var subject = "Whatever you like"
var sb_recipient = sb_user + "@" + sb_domain
var image = "<img alt='Contact Me' xsrc='images/e.png' height='13' width='187' style='vertical-align:bottom;border:0' />"
var sb_url = "mailto:" + sb_recipient + "?subject=" + escape(subject)
document.write(image.link(sb_url));

* The ‘/’ at the end of the image is for XHTML – if you are using HTML doctypes, leave it out.

(3) Save the file as whateveryoulike.js in your js includes directory or wherever you wish.

(4) Link to your .js script in the body of the page where you want it to appear as follows:

<script language="JavaScript" xsrc="directorywhereyousavedthescript/whateveryoulike.js" mce_src="directorywhereyousavedthescript/whateveryoulike.js" type="text/javascript"></script><noscript>Email Me</noscript>

Good luck in thwarting spammers!

Sphere: Related Content

Comments are closed.

"Those who seek to bestow legitimacy must themselves embody it, and those who invoke international law must themselves submit to it."

- Kofi Annan, 2004
Go to the Top of the Page
Search this Site
Sibagraphics
ABN40098165406 / QLD BN17649330
P.O. Box 259, Pomona, Qld Australia 4568
Ph: +61 (0)7 5485 2085
Mob: +61 (0)412 665 189

Visitor locations

Valid XHTML 1.0 / Valid CSS Copyright | Privacy | Disclaimer
Copyright © 1998 - 2009 Sibagraphics
Page last modified July 30, 2010.