Using JavaScript with XHTMLThe XHTML DTD defines the Script elements as #PCDATA. Therefore the < sign, the ampersand (&) and other characters contained in Scripts (e.g. JavaScript) will be interpreted as entity references. To avoid this interpretation one must wrap the content of our Scripts within a CDATA marked selection. This condition applies for Scripts written in any language, not just JavaScript. Alternatively, you can use external Scripts. Using JavaScript in XHTML documents Using an External JavaScript file in XHTML
Using JavaScript in XHTML documents
Note that good-old HTML Script hiding (example below) will not
work.
Using an external JavaScript file in XHTMLIf you call an external Script file, you don't have to worry about adding anything special to either the calling file or the external file. A sample call to an external Script file follows:
|