Detect Metro UI Version of IE

后端 未结 11 1782
轻奢々
轻奢々 2020-12-02 21:22

What\'s the fastest method, to detect User-Agent as metro UI version of internet-explorer >=10 ?

11条回答
  •  暖寄归人
    2020-12-02 21:28

    Here is a consistent method, with no ActiveX check dependency, as tested in IE10 and IE11 specifically.

    if (window.screenY === 0 && (window.innerHeight+1) !== window.outerHeight){ //IE metro/modern UI }
    

    The first rule detect IE's full screen or modern view (which may or can also be true on IEMobile). Maximized mode being historically always associated with positive or negative screenX and screenY.

    And the last rule excludes [Full screen/F11] mode, which for some reason constantly shows a 1px discrepancy between outerHeight and innerHeight as tested on IE10/Win8 and IE11/Win8.1

    PS: I voluntarily do not declare window.screenX === 0. Only use screenY in order to cover Modern/Metro in snap-mode with a window context snapped to the right (i.e. screenX !== 0).

提交回复
热议问题