Forum Moderators: open

Message Too Old, No Replies

Validating my 'scramble e-mail address' code

Or more accurately, my inability to do the above.

         

ritch_b

4:34 pm on Mar 17, 2003 (gmt 0)

10+ Year Member



Better late than never, I've just got round to removing the normal mailto: links from my site with the intention of replacing them with some Javascript that displays the address in a conventional manner, but prevents harvesters from collecting the e-mail address.

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.

hutcheson

7:37 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried:

document.write("<","/a>");

It may not validate, but it'll sure not get the same error.

bird

8:27 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your code doesn't show the opening tag to the validator, then you'll have to hide the closing tag as well. I'd try something linke this:

i++; document.write(unescape('%3C/a%3E'));

g1smd

9:04 pm on Mar 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i++; document.write('</a>'); -- will always produce an error.

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".

malexandrou

7:06 pm on Mar 18, 2003 (gmt 0)

10+ Year Member



This isn't an answer to your question, but it is related.

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

ritch_b

12:42 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



Thanks peeps - have gone for the i++; document.write('</' + 'a>'); option which I wouldn't otherwise have thought of in a million years.

Works like a charm, validates a treat!

Cheers.

R.

bill

1:00 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The people over at Hiveware [hiveware.com] have put out a very nice HTML & XHTML validating freeware product that encodes your e-mail addresses. Over the past few months the product has evolved quite impressively.

ritch_b

1:18 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



It's Hiveware's Enkoder I've ended up going with - most impressive, but still doesn't output valid HTML!

R.

bill

1:31 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The last one I put on my site validated...;) At least I thought it did. They use their own code on their site for e-mail and the site validates...
About This Site
This site has been lovingly hand-coded in XHTML 1.0-Transitional - which validates, no less.

hmmmm

ritch_b

2:03 pm on Mar 21, 2003 (gmt 0)

10+ Year Member



Just gave it another try for the hell of it - and to make sure I hadn't done another of my classic c*ck-ups.

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.

g1smd

10:46 pm on Mar 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Perhaps you could email them this link:
[webmasterworld.com...]