Unstoppable Domains

Problem validating javascript with xhtml

Spaceship 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.
AfternicAfternic

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back