/ 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.
Expand |
Embed | Plain Text
/* * Author: Aaron Alexander (nerdfiles.net) */ var baseDomain = "test.com"; var baseEmailDomain = "test.com"; $(document).ready(function(){ /* Since the "target" attribute is no longer permitted under the XHTML 1.0 Strict specification See (for a discussion): http://robertnyman.com/2006/02/13/how-evil-is-the-target-attribute/ Example: <a href="http://google.com" rel="external">google.com</a> */ $("a[rel='external']").addClass("external-link"); $("a[rel='external']").click(function(event) { window.open(this.href); event.preventDefault(); }); /* A poor man's e-mail obfuscation Checks to see if rel attribute has "email" then grabs the preceding word. Example: <a href="#" rel="e-mail handle">com.tset@eldnah</a> */ $("a[rel^='e-mail']").css({ "unicode-bidi": "bidi-override", "direction": "rtl", }); $("a[rel^='e-mail']").click(function(event) { var str = this.rel; var emailHandle = str.replace(/e-mail /, ""); window.location = "mailto:" + emailHandle + "@" + baseEmailDomain; event.preventDefault(); }); });
You need to login to post a comment.
