nick — 2008-05-23T06:43:24-04:00 — #1
jimmyp — 2008-05-23T07:02:02-04:00 — #2
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 )
autisticcuckoo — 2008-05-23T09:13:01-04:00 — #3
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
nick — 2008-05-23T09:35:33-04:00 — #4
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';
autisticcuckoo — 2008-05-23T13:21:56-04:00 — #5
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
nick — 2008-05-23T14:05:41-04:00 — #6
Thanks for your help, Tommy. I think I'll just move my JS to an external file.
cssiscool — 2008-06-09T20:50:14-04:00 — #7
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
autisticcuckoo — 2008-06-10T01:36:13-04:00 — #8
You can't use
document.write() with XHTML. See Why document.write() doesn't work in XML if you don't know why,