Ie Conditional Code Not Working (Using Jade)

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!

2

1 Answer

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest