jQuery Plugin To Protect Email Addresses From Spambots - MailTo

jQuery Plugin To Protect Email Addresses From Spambots - MailTo
File Size: 5.1 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

MailTo is a jQuery plugin that obfuscates/hides your email addresses on the webpage to protect them from crawlers and bots.

See also:

How to use it:

1. Download the MailTo plugin and include the minified version after jQuery JavaScript library.

<script src="//code.jquery.com/jquery-1.12.1.min.js"></script>
<script src="jquery.mailto.js"></script>

2. Add email's account name, host name and subject using html5 data attributes as follows:

<a class="email" 
   data-account="webmaster" 
   data-host="jQueryscript.net" 
   data-subject="Contact us">
</a>

3. Initialize the plugin and done. In this case, the plugin will display the email address '[email protected]' with a 'mailto' link on your webpage.

$('.email').mailto();

4. You can also apply the plugin to any inline element like 'span'.

<span class="email" 
   data-account="webmaster" 
   data-host="jQueryscript.net" 
   data-subject="Contact us">
</span>

5. Available plugin options.

$('.email').mailto({

  // By default link text is the email address
  text: false, 

  // Default host
  host: window.location.hostname.replace('www.',''), 

  // Account
  account: false, 

  // Prepend email address
  prepend: false 
  
});

This awesome jQuery plugin is developed by sergiodlopes. For more Advanced Usages, please check the demo page or visit the official website.