javascript 如何在每个浏览器中检查缩放级别是否低于 100%(ctrl 和 - )?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14870651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check zoom level is below 100% (ctrl and - ) in each browser?
提问by user782104
In the browser by default the user can either use ctrl +/- or ctrl scroll to zoom in or zoom out the page. I would like to know is there any way to check the zoom level is below 100% and not doing something
默认情况下,在浏览器中,用户可以使用 ctrl +/- 或 ctrl scroll 来放大或缩小页面。我想知道有什么方法可以检查缩放级别是否低于 100% 并且不执行某些操作
eg. My code
例如。我的代码
$(window).resize(function() {
if ($(window).height() > 500 && $(window).width() > 600 && $('.royalSlider:visible').length < 1 && !isiPhone()){
//Not allow the page size < 0
Book.zoom_auto();
Book.book_position();
Book.dragdrop_init();
if ($(".viewportBinder").length){
$("#view").css('height',$(window).height());
$("#view").css('width',$(window).width());
content = element.viewport('update');
}
}
calculate_zoom_factor();
});
currently window resize is implement some function but I would like to add condition only zoom level >= 100%, thanks
当前窗口调整大小实现了一些功能,但我只想添加条件缩放级别 >= 100%,谢谢
采纳答案by user782104
Check the window size using this reference
使用此参考检查窗口大小
From the website, you can find that the zoom level is below 100% if
从网站上可以发现,如果缩放级别低于 100%
$(window).width() >= screen.width