[thelist] DOCTYPE Quirk in IE6

Peter-Paul Koch gassinaumasis at hotmail.com
Mon Mar 4 17:32:01 CST 2002



>I have tried unsuccessfully to get my menu-driven DHTML/Javascript code to
>work in IE6.  It does not work if I have as my first line of code:
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>"http://www.w3.org/TR/html401/loose.dtd">
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>"http://www.w3.org/TR/html4/strict.dtd">
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict file://EN">
>
>This DOES work.  Why?
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

What happens when you don't use a doctype at all? Probably the script works.

The problem is most likely that somewhere it uses document.body . When you
use a doctype in IE6, all properties of document.body are reassigned to
document.documentElement .

Either add another object detection routine, like

if (document.documentElement && document.documentElement.scrollTop)
   // do something with document.documentElement.scrollTop
else if (document.body && document.body.scrollTop)
   // do something with document.body.scrollTop

or remove the doctype entirely.

ppk

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com




More information about the thelist mailing list