PDA

View Full Version : script lacking { 's can be a source for errors validating xhtml?



ricmetal
11-14-2007, 02:21 AM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem: i cant validate my xhtml webpage & the errors are comming from the javascript code

basicly thats the problem.

...

when i validate a xhtml webpage, i get allot of errors comming from the javascript.

i noticed theres a lack of { and } so im wondering if that affects the validation.

thanks
ric

edit:

i just made a direct validation of the script which i downloaded and did not edit and the XHTML and its gives out errors

the reason im pointing this out is because im having trouble setting some height attributes in css to a few tables and i wanted to make sure the website had no errors before i looked into the situation, but im finding errors on the original script provided...

ric

ddadmin
11-14-2007, 04:56 AM
Wrap the script on the page with a CDATA tag as discussed on this page: http://www.dynamicdrive.com/style/blog/entry/updating-a-javascript-to-be-xhtml-compliant/

jscheuer1
11-14-2007, 01:08 PM
Wrap the script on the page with a CDATA tag as discussed on this page: http://www.dynamicdrive.com/style/blog/entry/updating-a-javascript-to-be-xhtml-compliant/

That is one of several methods. You probably shouldn't be using an XHTML DOCTYPE to begin with, and removing it in favor of:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

However, that alone will not solve many of the possible 'on page' javascript errors generated by the validator. Opinions vary as to the correctness of these error reports. They may all be eliminated though by making the script an external one.

ricmetal
11-15-2007, 02:08 AM
thanks ddadmin..


jscheuer1, i tried allot of different doctypes, all give errors so im just gonna change doctypes as i add code to the page.

fortunately my height problem had nothing to do with the javascript not being validated ('few'!)

thanks for ur help.

ric

jscheuer1
11-15-2007, 04:51 AM
I never said the DOCTYPE was the problem. I only said that you probably shouldn't be using an XHTML DOCTYPE. Separately I mentioned that there are several ways to 'validate' (actually to validate a page with javascript, validating javascript as javascript is another matter entirely) javascript, and that the best method is generally to make the script external.