Detect IE version (prior to v9) in JavaScript

前端 未结 30 1770
半阙折子戏
半阙折子戏 2020-11-22 08:44

I want to bounce users of our web site to an error page if they\'re using a version of Internet Explorer prior to v9. It\'s just not worth our time and money to

30条回答
  •  耶瑟儿~
    2020-11-22 09:04

    I'm going to recommend not rewriting this code for the umpteenth time. I would recommend you use the Conditionizr library (http://conditionizr.com/) which is capable of testing for specific IE versions as well as other browsers, operating systems, and even the presence or absence of Retina displays.

    Include the code for only the specific tests you need and you also gain the benefit of a tested library which has been through many iterations (and which would be easy to upgrade without breaking your code).

    It also meshes nicely with Modernizr which can handle all of those cases where you are better off testing for a specific capability rather than a specific browser.

提交回复
热议问题