[whatwg] HTML syntax: comments before doctype and doctype sniffing

Philip Taylor excors+whatwg at gmail.com
Mon Jun 18 14:42:46 PDT 2007


On 18/06/07, Martin Payne <martin-bulkmail at martinpayne.co.uk> wrote:
> Philip Taylor wrote:
> > In Firefox 2:
> >
> > javascript:s='<?>';for(i=0;i<1006;++i)s+='
> > ';window.location='data:text/html,'+s+'<!doctype
> > html><script>document.write(document.compatMode)</script>'
> >
> > javascript:s='<?>';for(i=0;i<1007;++i)s+='
> > ';window.location='data:text/html,'+s+'<!doctype
> > html><script>document.write(document.compatMode)</script>'
> >
> > The first produces CSS1Compat, the second BackCompat.
>
> Not for me it doesn't (Mozilla/5.0 (X11; U; Linux i686; en-US;
> rv:1.8.1.4) Gecko/20070603 Fedora/2.0.0.4-2.fc8 Firefox/2.0.0.4). Both
> render in standards mode for me.

Hmm, that might have been some unfortunate line wrapping - it's
probably better to write:

javascript:s='<?>';for(i=0;i<1006;++i)s+='%20';window.location='data:text/html,'+s+'<!doctype%20html><script>document.write(document.compatMode)</script>'

javascript:s='<?>';for(i=0;i<1007;++i)s+='%20';window.location='data:text/html,'+s+'<!doctype%20html><script>document.write(document.compatMode)</script>'

where each should be one line with no spaces. Then I get the
CSS1Compat/BackCompat difference when just copying those into the
location bar, in "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1.4)
Gecko/20070515 Firefox/2.0.0.4" and "Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.9a6pre) Gecko/20070618 Minefield/3.0a6pre".

(IE7 and Opera 9 don't appear to have any limit on how early the
doctype should appear.)

-- 
Philip Taylor
excors at gmail.com



More information about the whatwg mailing list