Skip to content Skip to sidebar Skip to footer

Disabling Page Zoom In IE7 (jQuery/JS)

I know this is not the best thing to do in view of accessibility, but I have a genuine need to disable the user from zooming onto the page using CTRL+ in IE7. I got it working for

Solution 1:

This is better and correct way:

$(document).ready(function() {
    var ctrl = false;
    $(document).keydown(function(e){    
        // disable ctrl + +/-
        if(ctrl && (e.keyCode == 107 || e.keyCode == 109)) {
            alert('Zoom is disabled!');
            return false;
        }
        if(e.keyCode == 17) {
            ctrl = true;

            // disable ctrl + scroll
            $(document).bind('scroll', function() {
                if(ctrl) {
                    alert('Zoom is disabled!');
                    return false;
                }                               
            });
        }
    })

    $(document).keyup(function(e) {
        if(e.keyCode == 17) {
            ctrl = false;
            $(document).unbind('scroll');
        }                  
    });                    
});

Solution 2:

Try attaching keydown to document instead:

$(document).keydown(function (e) {

     alert('key is down');
     return false;
});

Solution 3:

This is pointless if the end user's browser already has the zoom set before visiting your page.


Solution 4:

simple answer. for IE, you need Event.stop(e); instead of return false;


Solution 5:

I don't have IE7 to test on ATM but this should do it

$(window).keydown(function (e) {
  alert('key is down');   // this fires             
  e.preventDefault();     // This is a standard jQuery way of 
                          // preventing the default action
  return false;           // Therefore you shouldn't need this.
});

Post a Comment for "Disabling Page Zoom In IE7 (jQuery/JS)"