本文介绍了使用javascript检测浏览器缩放级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户使用javascript更改浏览器的缩放级别和默认缩放级别时,可以检测浏览器缩放级别。我需要根据缩放级别更改调用不同的xml文件。
Is it possible to detect the browser zoom level when the user changed the zoom level of browser, and the default zoom level using javascript. I need to call different xml files according to the zoom level change.
推荐答案我发现你必须为每个浏览器:
I found that you have to vary for each browser:
这在safari和chrome中效果非常好:
This works great in safari and chrome:
zoom = parseInt(document.defaultView.getComputedStyle(document.documentElement, null).width,10)/document.documentElement.clientWidth这在IE8 +(除非你的用户有一些奇怪的屏幕....):
This works well in IE8+ (unless your user has some freakish screen....):
zoom = window.screen.deviceXDPI/96对于Firefox和IE7,我使用这 虽然我还没有它可以在Mac上使用Firefox ...
And for Firefox and IE7 I use this although I still haven't got it to work with Firefox on the Mac...
祝你好运。
更多推荐
使用javascript检测浏览器缩放级别
发布评论