Skip to content

Instantly share code, notes, and snippets.

@szbl
Created March 4, 2013 20:28
Show Gist options
  • Save szbl/5085348 to your computer and use it in GitHub Desktop.
Save szbl/5085348 to your computer and use it in GitHub Desktop.
Updated email obfuscation.
jQuery( document ).ready(function($){
//Email Encrypt
$(".email").each(function(){
var ats, dots, address, i;
ats = [ ' at ', ' (at) ', ' [at] ' ];
dots = [ ' dot ', ' (dot) ', ' [dot] ' ];
address = $(this).html();
for ( i = 0; i < ats.length; i++ )
{
while ( address.indexOf( ats[i] ) != -1 )
address = address.replace( ats[i], '@' );
}
for ( i = 0; i < dots.length; i++ )
{
while ( address.indexOf( dots[i] ) != -1 )
address = address.replace(dots[i], '.');
}
$(this).html('<a href="mailto:' + address + '">' + address + '</a>');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment