Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

W3C-Compliant Anti-Spam E-mail Links

Thread Tools
 
Search this Thread
 
Old 22 June 2005, 01:38 PM
  #1  
ScoobyDan
Scooby Regular
Thread Starter
 
ScoobyDan's Avatar
 
Join Date: Apr 2001
Location: West Sussex
Posts: 227
Likes: 0
Received 0 Likes on 0 Posts
Question W3C-Compliant Anti-Spam E-mail Links

Hi All,

I have created a website for a philanthropic organisation I am a member of (www.brightonpgl.co.uk). I do not want the e-mail addresses to get harvested by spambots, so I use a simple bit of JavaScript to generate the addresses.
Code:
  <script language="javascript" type="text/javascript">
   var user = "bro.dhobbs";
   var domain = "gmail";
   var suffix = "com";
   var display = "Contact the webmaster";
   document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '">' + display + '</a>');
  </script>
Unfortunately, this means the page will not validate with the W3C (see http://validator.w3.org/check?uri=www.brightonpgl.co.uk), giving the error "document type does not allow element 'a' here".

I have tried a number of different solutions (moving the Javascript to a function in the HEAD section, trying different combinations of text and variables, etc), but nothing validates. Any ideas how I get around this, while still preventing the spambots from grabbing the addresses?

Thanks

Daniel
Old 22 June 2005, 02:01 PM
  #2  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Default

Here:

http://www.htmlhelp.com/tools/validator/problems.html
Old 23 June 2005, 08:49 AM
  #3  
ScoobyDan
Scooby Regular
Thread Starter
 
ScoobyDan's Avatar
 
Join Date: Apr 2001
Location: West Sussex
Posts: 227
Likes: 0
Received 0 Likes on 0 Posts
Default

Steven,

Thanks for that. I have now extracted the JavaScript into a seperate file (something I should have done anyway, but I was being lazy!). Now both XHTML and CSS valid!

Daniel
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Rbon91
ScoobyNet General
49
21 November 2018 03:23 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
south_scoob
ScoobyNet General
22
03 October 2015 01:05 PM
Ganz1983
Subaru
5
02 October 2015 09:22 AM
Flat4x4-again
General Technical
2
29 September 2015 06:32 PM



Quick Reply: W3C-Compliant Anti-Spam E-mail Links



All times are GMT +1. The time now is 12:30 PM.