最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect zoom level on all modern browsers - Stack Overflow

programmeradmin0浏览0评论

I was wondering if there's a way to detect the page zoom level which is supported by all modern browsers. I've already tried this: how-to-detect-page-zoom-level-in-all-modern-browsers

but unfortunately it is not fully patible with all the browser I tried.

Is there a more general method, or a jquery library to achieve that?

I was wondering if there's a way to detect the page zoom level which is supported by all modern browsers. I've already tried this: how-to-detect-page-zoom-level-in-all-modern-browsers

but unfortunately it is not fully patible with all the browser I tried.

Is there a more general method, or a jquery library to achieve that?

Share Improve this question asked Feb 23, 2015 at 14:51 user3098549user3098549 1,2593 gold badges14 silver badges26 bronze badges 3
  • Did you had any luck? – jason Commented Jul 16, 2015 at 0:52
  • 1 Possible duplicate of How to detect page zoom level in all modern browsers? – ZachB Commented Oct 19, 2018 at 23:23
  • This might be helpful: sitelint./blog/detect-browser-zoom-level – Cezary Tomczyk Commented Nov 16, 2023 at 20:41
Add a ment  | 

1 Answer 1

Reset to default 6

It depends on what your goal. If you only need the current scaling you can use:

window.devicePixelRatio

But the value is not equal to the zoom level on all devices because on HighDPI devices (4k Display, Smartphone, …) the start value is not 1 because there is a default zoom to pensate the higher pixel resolution.

发布评论

评论列表(0)

  1. 暂无评论