Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

XHTML validating and Javascript bug

I discover that if I generate dynamic HTML using
client side Javascript, the XHTML validator will screw
up the whole page!

Has this been brought up before?

Amour Tan
Wednesday, November 5, 2003

yes it has.  Be sure your javascript is written properly for xhtml.  The same thing happens for style tags in the wrong place.

Try writing your js stuff in different article and include it.

Joel Goldstick
Wednesday, November 5, 2003

I discovered that there are also some "preserve
whitespace" tag in my Javascript code after running it
through the validator.

Also, the validator will move my Javascript code from
somewhere in the middle of the page to the top of the
page!  This totally screw up how my "document.write()"

As I am new to Javascript, I need advice on how to get
around these issues.

Amour Tan
Wednesday, November 5, 2003

You need to put javascript inside CDATA markup tags in xhtml.  Maybe that is your problem?

Joel Goldstick
Wednesday, November 5, 2003

I do have the "CDATA" tag.  But it still insisted on moving
the block of Javascript code to the top of the web page.

Amour Tan
Wednesday, November 5, 2003

Just another idea. 
1. Create an article  with the words "TEST TEST" and  preview it using your standard template.  This will give you the complete results of your template. 

2. Then, use the browsers "view source" feature to view and copy the html to your clip-board.

3. Create a file in Citydesk -- call it "test.html".  Paste results from step two into test.html.

4. Next, edit test.html -- insert the code with javascript that you are having problems with into test.html where you see the words "TEST TEST".  Publish that file. 

5. Finally, publish test.html to the web.  Use the wc3 validation tools to validate your code. 

You very likely will find some invalid markup.  Solve those problems and your moving javascript may go away.

Joel Goldstick
Thursday, November 6, 2003

*  Recent Topics

*  Fog Creek Home