Most likely, you have a DOCTYPE on your page, generally that is a good thing but, this script was written before the wide use of DOCTYPEs and so must be upgraded to work with them.
With many of the scripts of this type all that is required is to change all instances of:
But, in some older browsers, this will make problems so what can be done is to change all document.body references to:
and put this function in the script block before any occurrences of iecompattest():
Sometimes references to position and/or styled (not attributed) dimensions in the script must be made to use pixels but, this does not appear to be a problem in this script.
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body