Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoom in/out events in jQuery

Tags:

jquery

zooming

I simply want a function that show alert on zoom in window saying like "you zoomed in" and on zoom out saying like "you zoomed out", I searched for this function for lot of time but every time I search I get like "zooming into window event" and that's not what I'm looking for.

like image 569
user2401856 Avatar asked Dec 26 '22 03:12

user2401856


1 Answers

srceen.width is fixed value but where as window.innerWidth value will change as per the zoom effect. please try the below code:

 $(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%")
       }
    });
like image 138
Dinnu Buddy Avatar answered Jan 13 '23 14:01

Dinnu Buddy