Archive for JavaScript

emailCloak 1.0: a simple jQuery plug-in

// October 11th, 2009 // No Comments » // JavaScript, Web Development

Something that comes up time and time again in my development is how to protect email addresses on websites from spam email harvesters. To solve it, I wrote a simple jQuery plug-in which takes a specifically formatted string and turns it into an email on the fly. I’ve found it terribly handy and hopefully, you might find it useful too!

Usage is really simple, just referene the script (in the ZIP file) and include this bit of code at the bottom of your page:

$(document).ready(function() {
    $('#id-of-element').uncloak({
        atSeparator: '[at]', (default)
        dotSeparator: '||', (default)
        altText: 'Contact this company'
    });
});

And it’s expecting the element to conaint a string in the format of:

user [at] example.com

It’s unlicensed so feel free to do with it what you please. :)

Download emailCloak 1.0