NameSilo

Problem validating javascript with xhtml

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

gamex

Established Member
Impact
7
Problem validating javascript with xhtml - RESOLVED

I have a PHP function where I type in an email address and it will print out a javascript to display my email address to protect it from email harvesters.

The output looks like this:

<script type="text/javascript">
emailAddy='domain.com'
emailAddy=('someperson' + '@' + emailAddy)
document.write('<a href="mailto:' + emailAddy + '">' + emailAddy + '</a>')
</script>

However, when I validate the page at w3.org, I get this error:

Line 57, column 50: document type does not allow element "a" here

document.write('<a href="mailto:' + emailAddy + '">' + emailAddy + '</a>')

I made the greater than sign red because thats what the validator shows me. Any ideas?




EDIT: PROBLEM SOLVED!!!!

I spent half an hour trying to figure out a solution before I posted it, and of course, 10 minutes after I posted it, I figured it out. I just had to put put the comment tags inside my script :)

<script type="text/javascript">
<!--
emailAddy='domain.com'
emailAddy=('someperson' + '@' + emailAddy)
document.write('<a href="mailto:' + emailAddy + '">' + emailAddy + '</a>')
-->
</script>
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Appraise.net

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back