Posted By

nerdfiles on 07/13/09


Tagged

window jquery external e-mail Obfuscation


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

cnsaturn


JS External Windows and Poor Man's E-mail Obfuscate (jQuery)


 / Published in: JavaScript
 

Basically, this is my "common.js" document which I use as the base for all my Web sites. So, these functions are just general purpose. So, the question is: Would a spam bot check the rel tag for the actual handle? It won't get the domain from the link on the page. And you can take out the right-to-left condition to make it a left-to-right, non-e-mail address link.

The external link script is for semantic purposes, since "target" has been deprecated.

  1. /*
  2.  * Author: Aaron Alexander (nerdfiles.net)
  3.  */
  4.  
  5. var baseDomain = "test.com";
  6. var baseEmailDomain = "test.com";
  7.  
  8. $(document).ready(function(){
  9.  
  10. /*
  11. Since the "target" attribute is no longer permitted under the XHTML 1.0 Strict specification
  12. See (for a discussion): http://robertnyman.com/2006/02/13/how-evil-is-the-target-attribute/
  13. Example: <a href="http://google.com" rel="external">google.com</a>
  14. */
  15. $("a[rel='external']").addClass("external-link");
  16.  
  17. $("a[rel='external']").click(function(event) {
  18. window.open(this.href);
  19. event.preventDefault();
  20. });
  21.  
  22. /*
  23. A poor man's e-mail obfuscation
  24. Checks to see if rel attribute has "email" then grabs the preceding word.
  25. Example: <a href="#" rel="e-mail handle">com.tset@eldnah</a>
  26. */
  27. $("a[rel^='e-mail']").css({
  28. "unicode-bidi": "bidi-override",
  29. "direction": "rtl",
  30. });
  31.  
  32. $("a[rel^='e-mail']").click(function(event) {
  33. var str = this.rel;
  34. var emailHandle = str.replace(/e-mail /, "");
  35. window.location = "mailto:" + emailHandle + "@" + baseEmailDomain;
  36. event.preventDefault();
  37. });
  38.  
  39. });

Report this snippet  

You need to login to post a comment.