Best way to check for IE less than 9 in JavaScript without library

前端 未结 14 1741
失恋的感觉
失恋的感觉 2020-11-28 21:10

What would be your fastest, shortest (best) way to detect browser which is IE and version less than 9 in JavaScript, without using jQuery or any add-on libraries?

14条回答
  •  死守一世寂寞
    2020-11-28 21:24

    bah to conditional comments! Conditional code all the way!!! (silly IE)

    
    

    Seriously though, just throwing this out there in case it suits you better... they're the same thing, this can just be in a .js file instead of inline HTML

    Note: it is entirely coincidental that the jscript_version check is "9" here. Setting it to 8, 7, etc will NOT check "is IE8", you'd need to lookup the jscript versions for those browsers.

提交回复
热议问题