javascript - Loading different css to IE -


so i'm trying load different css stylesheet if ie detected.

my code:

<head> <!-- other scripts , stylesheets -->  <!--[if ie]>   <link href='css/index_ie.css' rel='stylesheet' type='text/css'> <![endif]--> <!--[if !ie]>   <link href='css/index.css' rel='stylesheet' type='text/css'> <![endif]-->  <script> (function() {     if (typeof activexobject === "undefined") {         var s = document.createelement('link');         s.href = "css/index.css";         s.rel = "stylesheet";         s.type = "type/css";         document.documentelement.appendchild(s);     }     else {         var s = document.createelement('link');         s.href = "css/index_ie.css";         s.rel = "stylesheet";         s.type = "type/css";         document.documentelement.appendchild(s);     } })(); </script> </head> 

this loads index.css correctly when not-ie browser. not loading index_ie.css when ie being used.

ps: testing ie 10

to include content in browsers other ie 9 , older, use slightly different syntax:

<![if ie]>   <link href='css/index.css' rel='stylesheet' type='text/css'> <![endif]> 

as explains:

the downlevel-revealed conditional comment enables include content in browsers don't recognize conditional comments. although conditional comment ignored, html content inside not.

though, note conditional comments aren't supported after ie 9 (from top of same page):

important of internet explorer 10, conditional comments no longer supported standards mode. use feature detection provide effective fallback strategies website features aren't supported browser. more info standards mode, see defining document compatibility.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -