This is a common problem. The validator is trying to validate the code within the <script> tags as if it were active HTML on the page. It's essentially just an error by the validator itself. Surprisingly, even wrapping the code in a CDATA section doesn't seem to cure the problem for that DOCTYPE. That approach
does work for XHTML.
One simple solution is to put your page-specific Javascript in a separate config file, then just call it from the page, like:
Code: Select all
<script type="text/javascript" src="../highslide/highslide.js"></script>
<script type="text/javascript" src="highslide.config.js"></script>
The highslide.config.js file would contain:
Code: Select all
hs.registerOverlay({
html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
position: 'top right',
fade: 2 // fading the semi-transparent overlay looks bad in IE
});
But the best solution of all is to ditch HTML 4.01 Transitional, and use HTML5. The HTML and XHTML "transitional" DOCTYPE's were intended to smooth the transition from HTML 3 to HTML 4 -
in 1997. It's well past time to let them go! In HTML5, that chunk of code in a <script> tag validates without complaint.