How do I detect IE 8 with jQuery?

前端 未结 12 1412
一生所求
一生所求 2020-11-30 19:14

I need to detect not only the browser type but version as well using jQuery. Mostly I need to find out if it is IE 8 or not.

I am not sure if I am doing it correctly

12条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 19:28

    You can use $.browser to detect the browser name. possible values are :

    • webkit (as of jQuery 1.4)
    • safari (deprecated)
    • opera
    • msie
    • mozilla

    or get a boolean flag: $.browser.msie will be true if the browser is MSIE.

    as for the version number, if you are only interested in the major release number - you can use parseInt($.browser.version, 10). no need to parse the $.browser.version string yourself.

    Anyway, The $.support property is available for detection of support for particular features rather than relying on $.browser.

提交回复
热议问题