How to detect page zoom level in all modern browsers?

后端 未结 28 1846
慢半拍i
慢半拍i 2020-11-21 05:27
  1. How can I detect the page zoom level in all modern browsers? While this thread tells how to do it in IE7 and IE8, I can\'t find a good cross-browser solution.

28条回答
  •  旧巷少年郎
    2020-11-21 06:09

    You can use the Visual Viewport API:

    window.visualViewport.scale;
    

    It is standard and works both on desktop and mobile: browser support.

提交回复
热议问题