How to check zoom level is below 100% (ctrl and -

2019-04-09 10:34发布

问题:

This question already has an answer here:

  • How to detect page zoom level in all modern browsers? 24 answers

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

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

回答1:

Check the window size using this reference

From the website, you can find that the zoom level is below 100% if

$(window).width() >= screen.width