Home > Software design >  IE conditional code not working (using Jade)
IE conditional code not working (using Jade)

Time:12-17

I am trying to use IE conditional code in Jade, and I tried:

mixin ie(condition)
    | <!--[!{condition}]><!-->
    block
    | <!--<![endif]-->
 ie('if !IE')
    div...

and also

mixin ie(condition)
    | <!--[!{condition}]>
    block
    | <![endif]-->
 ie('if !IE')
    div...

I want to make it so that the code from div on is invisible in IE.
But in the first case the code is still visible in Internet Explorer, and in the second case it gets completely commented out in every browser.
I feel like I am missing something, please help me out!

CodePudding user response:

As Yu Zhou mentioned:
The problem was just that IE conditional code does not work from IE 10 and on.
I instead used a js code to detect IE up to 10 like this:

        function detectIE() {
            var ua = window.navigator.userAgent;

            var msie = ua.indexOf('MSIE ');
            if (msie > 0) {
                return true;
            }

            var trident = ua.indexOf('Trident/');
            if (trident > 0) {
                return true;
            }

            return false;
        }

And then added the components depending on the browser.

  • Related