if condition: if the browser is IE and IE browser version is older than 9

前端 未结 9 1168
时光说笑
时光说笑 2020-12-24 09:17

The if condition below I think it says - if the browser is IE and IE browser version is newer than 9, but I don\'t have IE 9 to test it so it is hard to know the correct out

9条回答
  •  旧时难觅i
    2020-12-24 09:52

    There's an even easier method.

    Since this is a comment, it will be ignored by all other browsers except IE.

    var IE;
    //@cc_on IE = navigator.appVersion;
    

    Then just use this in you'r script to detect all IE versions.

    if (IE) {
    //This is IE.
    }
    else {
    //This is NOT IE.
    }
    

    Or match against any version like this:

    if (IE <= 6) {}, if (IE < 9) }, if (IE == 7) {} etc etc...
    

    Here's the source where i found these types of conditionals: http://www.javascriptkit.com/javatutors/conditionalcompile.shtml

提交回复
热议问题