HTML & CSS
It is because XHTML elements and attributes have to be lowercase. You currently have "onClick"; try "onclick" with a lower case "c".
( see here: http://www.w3.org/TR/xhtml1/#h-4.2 )
And there should be no
onclick attribute is script code, not a URI. You should use the
Content-Script-Type HTTP header (or a meta equivalent) to specify that the content type for inline script code is
Thanks, so like this?
Also, I am getting one more error:
document type does not allow element "a" here.
I'm not sure what that means? Does it just mean that I should replace > with > ?
if(page == '2')
document.getElementById('row1').style.display = 'none';
document.getElementById('row2').style.display = 'none';
document.getElementById('row3').style.display = 'table-row';
document.getElementById('row4').style.display = 'table-row';
Yes, here you'll run into a tricky one. The problem is that the content declaration of the
script element type is different in HTML and XHTML. In HTML it's declared as
CDATA, while XHTML declares it as
(#PCDATA). There's a big difference in how characters like '<' and '&' are handled.
Now, if you are using real XHTML this won't be a problem. Just escape all instances of '<' and '&' with '<' and '&'. If you are using pretend-XHTML (served as HTML), then you're in a fix. You can't do the escape thing, because that won't work when the document is parsed as HTML – which it must be if you serve it as
Or you could replace the
.innerHTML (which may not be such a great idea with XHTML to begin with) with proper DOM functions, but that'll get you into another problem, since for XHTML you should use
document.createElementNS() etc, while HTML requires
Thanks for your help, Tommy. I think I'll just move my JS to an external file.
yes onClick must be onclick. but this doesn't work in all cases.
document.writeln('<a href="http:\\/\\/www.yahoo.com\\/" class="off" onmouseover="this.className=\\'on\\'" onmouseout="this.className=\\'off\\'">Yahoo<\\/a>');
here is a form you can use to make your own document.writesthat i downloaded fron about.com
You can't use
document.write() with XHTML. See Why document.write() doesn't work in XML if you don't know why,
This topic is now closed. New replies are no longer allowed.