styleSheets array - link vs @import

Hello.

With this markup:

  <link href="/css/mystyle.css" rel="stylesheet" type="text/css">
  <style type="text/css">
    [some style rules]
  </style>

followed by this script:

  <script type="text/javascript">
  alert('length=='+document.styleSheets.length);
  ...

the alert gives length==2 in MSIE, Firefox and Opera, while in Google Chrome
it gives length==1;

Change the linked stylesheet to imported stylesheet, e.g.:

  <style type="text/css">
    @import url(/css/mystyle.css);
  </style>
  <style type="text/css">
    [some style rules]
  </style>

and Google Chrome gives length==2;

Clearly, Google Chrome is not creating an index in the styleSheets array for
a stylesheet loaded via a LINK until that stylesheet is completely loaded.

Is *correct* behavior specified anywhere?

David P

Received on Thursday, 25 June 2009 22:34:17 UTC