LiteTest
01 Jan 2010, 02:31 PM
I recently wrote a jQuery plugin for concealing email addresses on your website.
A while ago I helped a friend setup a website with no serverside coding at all.
There are still sites out there (along with people who only write html, and no serverside code) that are pure html.
The lack of contact forms (or for whatever reason) makes it necessary to include the mailto: attribute in the <a> tags.
This is pure chocolate cake for bots, crawling around looking for potential victims to spam, and nobody wants that!
For that reason, I wrote a simple jQuery plugin that would change the <a> tags.
Okay, enough drivel, let's get to it:
This can be done in 3 simple steps:
1) Change all
<a href="mailto:name@domain.com">email me</a>
to
<a href="name@domain.com" class="mailto">email me</a>
(Note: the class name is just a jQuery selector)
2) include the email plugin (can be found here (http://www.litetest.com/Content/Script/lt.emailencode.js)) in your page header
3) In your document.ready call, add this code
$(document).ready(function() {
$(".mailto").emailencode();
});
All done!
Your email won't appear as standard mailto link and bots won't get their mitts on your email address, but your visitors can still benefit from using them.
For more details and download link visit the ResourcePage (http://www.litetest.com/Resources.aspx/EmailEncode) on litetest.com
A while ago I helped a friend setup a website with no serverside coding at all.
There are still sites out there (along with people who only write html, and no serverside code) that are pure html.
The lack of contact forms (or for whatever reason) makes it necessary to include the mailto: attribute in the <a> tags.
This is pure chocolate cake for bots, crawling around looking for potential victims to spam, and nobody wants that!
For that reason, I wrote a simple jQuery plugin that would change the <a> tags.
Okay, enough drivel, let's get to it:
This can be done in 3 simple steps:
1) Change all
<a href="mailto:name@domain.com">email me</a>
to
<a href="name@domain.com" class="mailto">email me</a>
(Note: the class name is just a jQuery selector)
2) include the email plugin (can be found here (http://www.litetest.com/Content/Script/lt.emailencode.js)) in your page header
3) In your document.ready call, add this code
$(document).ready(function() {
$(".mailto").emailencode();
});
All done!
Your email won't appear as standard mailto link and bots won't get their mitts on your email address, but your visitors can still benefit from using them.
For more details and download link visit the ResourcePage (http://www.litetest.com/Resources.aspx/EmailEncode) on litetest.com