Forum Moderators: open
So far though, all the scripts I've found at Spamcon [spamcon.org] don't validate when passed through the W3 validator and have the same basic error :
Line 141, column 24: end tag for element "A" which is not open...i++; document.write('</a>');
Has anyone experience of a script that does validate, or might this be something I'll just have to put up with?
Suggestions much appreciated.
R.
I usually use
i++; document.write('</' + 'a>'); -- broke up the tag
or
i++; document.write('<\/a>'); -- escaped the "/"
Has anyone got any thoughts as to which of the four ways suggested, so far, is best, and why?
Even better, would be to store the Javascript code in external .js files, called using:
<script type="text/javascript" language="javascript" src="/path/file.js"></script>
at the point that the code is needed.
This has two major benefits. The code isn't seen by the validator at all. If you change your email address, or you want to change the way the hiding script works, you only have one file to edit.
One disadvantage: users without Javascript see no email address at all. For them, you should have a link inside a <noscript> tag that takes you to another page where you either have an email submit form, your email address shown as words (like "email the user joe.bloggs at the domain somewhere.com", or similar), or even better put the email address as words on a gif or jpg image file, or some other format that spiders cannot "read".
To avoid the potential problems with using Javascript to encode e-mail addresses, I've opted to convert e-mail addresses to their unicode equivalent. So the HTML code looks like gibberish, but the browser converts it to something readable for the user.
Eventually the spam bots will catch on, but I think it's a decent solution for the time being.
Do a search for e-mail cloaker using everyone's favorite search engine for more details about how this is done.
Marios
It produced code including the dreaded :
i++; document.write('</a>');
Which the validator doesn't seem to like. Easy fix though (now I know what to do!) and it's a pretty cool address scrambler, so not to worry!
R.