|
Mailing Lists
|
Home / Groups / Ajax
IE not including CSS>Hey all, > >My problem is that if the page retrieved from the >server pulls in a CSS file, like > ><link rel="stylesheet" type="text/css" >href="/theme/style2.css"> > >...the elements for this style sheet are not used >in the page that was retrieved. > >This is only a problem for IE, apparently, seems >to work fine on Firefox. Figured this one out - it's silly. Here's the "rules": IE will, indeed, load styles of any kind (linked via the <link> tag, declared in a <style> or inline with the "style" attribute) into a div (or whatever) via innerHTML. HOWEVER IE requires (for some reason) requires that the <style> or <link> tags are NOT the first elements on the page. For example this works: <p>Hello, how are you!</p> <link rel="stylesheet" href="insert.css" type="text/css"> <style> p { color: blue; } </style> But this does NOT: <link rel="stylesheet" href="insert.css" type="text/css"> <style> p { color: blue; } </style> <p>Hello, how are you!</p> IE needs something that affects the layout up there - all of the following can be "first" on the page and will allow IE to find styles: <br> <p>Something</p> <h1>something else</h1> But none of the following will work: <!-- A comment --> <p></p> <h1></h1> I've tested all of this in IE 6, FF 2 and Opera 9. I don't have IE 7 handy (will when I go home tonight). It's an odd bug - probably has something to do with the order of rendering but who knows. In any case it's easy to fix: just put your style last on your includable pages. (Note that this same "trick" doesn't work for scripts - they are still ignored in all browers. You'll still need something like my PanelManager to load them via innerHTML.) Jim Davis |
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||