[Javascript] mozilla & doctype Bug

Roger Roelofs rer at datacompusa.com
Wed Aug 24 08:18:09 CDT 2005


Laurent,

On Aug 24, 2005, at 8:38 AM, Laurent Muchacho wrote:

> javascript:
> document.getElementById('myDiv').style.width = '100';
>
> Usually this work fine crossbrowser in my code when I don't use any  
> doctype but soon as I place a doctype in my html code firefox stop  
> working

The reason this is true is that without a doctype (and with older  
ones like html 3.2) the firefox is in 'quirks' mode.  This mode has  
many hacks in it to support non-standard coding practices.  When you  
add a html 4.01 or xhtml doctype, firefox switches to 'standards' (or  
'almost-standards') mode where the dom will be more strict about what  
code it will accept.  So, change to

document.getElementById('myDiv').style.width = '100px';

hth

Roger
-------------------------------------------------------
Roger Roelofs                          web   www.datacompusa.com
Datacomp Appraisal Services   Email rer at datacompusa.com
3215 Eaglecrest Drive, NE
Grand Rapids, MI  49525-4593




More information about the Javascript mailing list