jQuery Safe Mail Plugin

Safe Mail for jQuery

Description

First off, let me apologize for the state of this page. I just wrote the plugin this morning, and needed somewhere to put the plugin, documentation and examples, so I threw this together from a Dreamweaver Template. I'll come back and clean things up when I get just a tad bit more time.

With the proliferation of spammers out there, scrapping email addresses off of web sites, this plugin for jQuery makes it easy to hide email address from spam bots.

The plugin is far from perfect, but it works, although I plan to expand on it as time permits. Usage is pretty straight forward, as shown below. The only caveat is that you need an element to append the mailto link to. You can simply place an empty div or span where you want the email link to appear, and access it using the id you have provided. For example:

<p>Here is a bunch of text in a paragraph, where I want an <span id='email_link'></span> to appear. Since the plugin appends to an element, I've included an empty span tag where I want the email address to appear.</p>

Download SafeMail

Usage

To use the email address as the link text:
$('#email_link').safe_mail("john.doe", "domain", "com");
Ouput: <a href="mailto:john.doe@domain.com">john.doe@domain.com</a>

To use some other text as the link text:
$('#email_link').safe_mail("john.doe", "domain", "com", "This is my email link text");
Ouput: <a href="mailto:john.doe@domain.com">This is my email link text</a>

Example

Here's a working example, in the fllowing paragraph, there are 2 email links, both are generated using the SafeMail plugin for jQuery. View source to look at the code.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec molestie. Sed aliquam sem ut arcu. Phasellus sollicitudin. Vestibulum condimentum facilisis nulla. In hac habitasse platea dictumst. Nulla nonummy. Cras quis libero. Cras venenatis. Aliquam posuere lobortis pede. Nullam fringilla urna id leo. Praesent aliquet pretium erat. Praesent non odio. Pellentesque a magna a mauris vulputate lacinia. Aenean viverra. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Aliquam lacus. Mauris magna eros, semper a, tempor et, rutrum et, tortor.

About Us | Site Map | Privacy Policy | Contact Us | ©2007