17-04-2009

Javascript Correct way to include Javascript in XHTML

The CDATA tags need to be included for the page with javascript to validate as XHTML. They also should be commented out for older browser who don't understand CDATA tags:

<script type="text/javascript">
/* <![CDATA[ */
// content of your Javascript goes here
/* ]]> */
</script>

To include an external script you can just use this:

<script type="text/javascript" src="hello.js"></script>

Comments:

Your comment:

»

 

[x]