Disable or Prevent zooming(Ctrl+ or Ctrl-) in cross-browser

Disable or Prevent Browser zoom on , Ctrl+ or Ctrl-, and Ctrl + Mouse scroll.

In my one of application I need to prevent the user, to zoom in and out over all cross browser. For  a specific application I would like to disable or prevent the browser zooming feature. For this i have to stop all below way of zooming the browser window.

  1. Disable keyboard CTRL+ or CTRL- on browser window.
  2. Disable keyboard CTRL and Mouse scroll key

 

You can disable zoom in cross browser by Ctrl+ or Ctrl- or Using Ctrl Key + Mouse wheel Up or down by this code.

 

JQUERY:
[js] $(document).keydown(function(event) {
if (event.ctrlKey==true && (event.which == ’61’ || event.which == ‘107’ || event.which == ‘173’ || event.which == ‘109’ || event.which == ‘187’ || event.which == ‘189’ ) ) {
event.preventDefault();
}
// 107 Num Key +
// 109 Num Key –
// 173 Min Key hyphen/underscor Hey
// 61 Plus key +/= key
});
$(window).bind(‘mousewheel DOMMouseScroll’, function (event) {
if (event.ctrlKey == true) {
event.preventDefault();
}
});
[/js]

DEMO:


[paypal-donation]

About Vijay Dhanvai

A passionate blogger by heart and mind, I have been working in this field for 10 years now. A WordPress Professional, web developer and designer who intends to guide his readers about Web Design, WordPress, Blogging, Web Development, and more.

Leave a Reply