Thursday, February 18, 2010

How To Validate Inline Javascript in XHTML

Inline JavaScript Validation in XHTML

When a validator or modern browser finds inline JavaScript code in your XHTML code it will try to validate it as ‘parsed character data’ (PCDATA) causing undesired results. To prevent this, the JavaScript code needs to be declared as ‘character data’ (CDATA) as follows:

codepic.jpg

Note that the declarations are within comments to allow the CDATA to work with older browsers.

Add comment

Fill out the form below to add your own comments