Identify Browser - Internet Explorer

1

I need to know when the user accesses the website through Internet Explorer, execute a CSS. So that's fine, here is the code I used to apply CSS:

 <!--[if IE]>
        <link rel="stylesheet" type="text/css" href="app/template/css/apenas-ie.css" />
 <![endif]-->

But it is not working, unfortunately you are not identifying if it is Internet Explorer or not, because if you apply the css in the default cover page it gets, but inside this one does not.

Does anyone have a Script to check if the browser is Internet Explorer, regardless of the version, so I can then do an if and apply css? Note: I need this in Javascript.

    
asked by anonymous 09.11.2016 / 17:42

2 answers

1

Done. Here is the ID code:

<script type="text/javascript">
var isIE = /*@cc_on!@*/false || !!document.documentMode;
if(isIE == true){
    var ie = ' <link rel="stylesheet" type="text/css" href="app/template/css/apenas-ie.css">';
}else{
     var ie = '';
}
</script>
    
29.12.2016 / 19:11
0

There is a detector for your browser to understand about @media

Follow the example below:

<link rel="styleSheet" href="./teste-ie.css"/>
<link rel="styleSheet" href="./teste-chrome.css" media="screen and (-webkit-min-device-pixel-ratio:0)" />
<link rel="styleSheet" href="./teste-firefox.css" media="screen and (-moz-images-in-menus:0)" />

or

<style type="text/css">
/* Outros navegadores */
body {
    background: cyan;
}

/* Webkit (Chrome e Safari) */
@media screen and (-webkit-min-device-pixel-ratio:0) { 
    body {
        background: darkseagreen;
    }
}

/* Mozilla Firefox */
@media screen and (-moz-images-in-menus:0) {
    body {
        background: gold;
    }
}
</style>

No IE rule is a standard Microsoft leaves no value media or see below: link (there is another way to see)

    
09.11.2016 / 19:51