jQuery: How to detect window width on the fly?

后端 未结 4 578
栀梦
栀梦 2020-11-27 12:27

I have a scrolling element on my page (with the jScrollPane jQuery plugin). What I want to accomplish is a way to turn off the scrolling window by detecting the width of the

4条回答
  •  佛祖请我去吃肉
    2020-11-27 13:02

    I dont know if this useful for you when you resize your page:

    $(window).resize(function() {
           if(screen.width == window.innerWidth){
               alert("you are on normal page with 100% zoom");
           } else if(screen.width > window.innerWidth){
               alert("you have zoomed in the page i.e more than 100%");
           } else {
               alert("you have zoomed out i.e less than 100%");
           }
        });
    

提交回复
热议问题