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>
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:





