In my previous post on this issue I've made a mistake – resulting code was in fact not valid XHTML Strict!

The problem is, there is no language property for <script> tag in (X)HTML Strict! In my example, it was used to detect the version of Javascript in visitor's browser, but this technique today is considered obsolete and useless (see Javascript – Object detection at quirksmode). If you still care, let me tell you there is no elegant way to find out what version of Javascript do you have. For example, The Ultimate JavaScript Client Sniffer is a script 8kb in size and, looking at its code, there is no way to cut it down to just several lines. BTW, author explicitly notes:

This document is obsolete and the information in it should not be relied upon. The practices described here are not recommended and this document is provided only for historical reference. Please see the web-developer documentation index page for more up-to-date documentation.

Anyway, this is just wrong. Either try object detection or, if you absolutely must use it with (X)HTML Strict, resort to server-side JS version detection.

And now here is valid XHTML code for my example:

          <! COUNTER-->
<a href="" id="m">
<script type="text/javascript">
if (d.getElementById) {
var i=d.createElement("img");
<noscript><img src=";id=341994;t=84" 
height="18" width="88" alt="" /></noscript></a>


Please note that above I'm explicitly setting js variable to 10 which essentially means Javascript v1.0. Perhaps it would be wiser to remove it altogether but here I'm leaving it for compatibility with original script. There is also some code (screen size detection, Java (not Javascript) support) which may not work with older browsers and even generate errors on client side – it could be safer to disable it for their sake.