Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@taspts
Created June 2, 2015 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taspts/06f833f4cc4cfe069eaf to your computer and use it in GitHub Desktop.
Save taspts/06f833f4cc4cfe069eaf to your computer and use it in GitHub Desktop.
Javascript Anti Spam Email
<!-- Hiding email address using a function to write in document (DOM) -->
<script type="text/javascript">
//<![CDATA[
function AntiSpamEM(domain, id, name) {
email='"mail' + 'to:' +id + '@' + domain.replace(/%23/g,".") + '"'
return '<a href=' + email + 'onmouseover=' + email + 'onfocus=' + email + '>' + name + '</a>' ;
};
//]]>
</script>
<!-- Write Email link in DOM using function -->
<script type="text/javascript">
//<![CDATA[
document.write(AntiSpamEM('xxx%23yyyy%23org','xyz','contact'));
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment