6

Is it possible to disable the in-browser, full-page zoom in Firefox (activated by Ctrl +) for a webpage? How about for certain elements in a webpage? I just notice that sometimes elements look really weird when they are zoomed, and it might be nice to just disable the zooming completely for those elements.

Note: I know there a few ways to find the zoom level, but this is really wanting to actively work around it (which might not be a good idea anyway).

Jonathan Morgan
  • 320
  • 3
  • 12
  • 2
    Interesting question, but I don't think it's possible except maybe for a Flash movie – Pekka Jan 02 '11 at 14:47
  • 1
    Yes, that's probably what I expected. Second thoughts told me that because it was working round functionality that was in the browser, even if you could get it to work it would probably do the wrong thing in some circumstances. – Jonathan Morgan Jan 02 '11 at 14:55
  • This is an interesting question. I think I've seen sites where I was unable to resize anything (and no, they weren't in Flash) – NullUserException Sep 30 '11 at 02:41

1 Answers1

4

Using information gathered largely through this question: Catch browser's "zoom" event in JavaScript

I've been playing around with attempting to track browser zoom for the last day or so, and this is about as close as you can get without an onZoom standard event that you can kill.

document.observe('keydown', function (ev) {
  var key, keys = ['0'];
  var isApple = (navigator.userAgent.indexOf('Mac') > -1), isCmmd, isCtrl;
  if (window.event)
  {
    key = window.event.keyCode;
    isCtrl = window.event.ctrlKey ? true : false;
    isCmmd = window.event.metaKey ? true : false;
  } else {
    key = e.which;
    isCtrl = ev.ctrlKey ? true : false;
    isCmmd = ev.metaKey ? true : false;
  }
  if (isCtrl || (isCmmd && isApple)) {
    switch (key) {
      case 48: // 0
        // do not stop, or user could get stuck
        break;
      case 187: // +
      case 189: // -
        ev.stop()
        break;
      default:
        break;
    }
  }
});

Unfortunately, and I've been playing with this for a while now, and there isn't any surefire way to really disable it. The zoom options are still available through main application menus, so until a real method of tracking zoom (including after page reloads, which mostly impossible right now, and, besides, webkit exhibits some odd behavior when you attempt to track zoom).

Although many people would like to keep browser zoom more hidden, I can personally see the possible benefits of being able to observe zoom separately from resize, as they are mostly indistinguishable at this point (and that's if for no other reason at all).

Community
  • 1
  • 1
Adam Eberlin
  • 14,005
  • 5
  • 37
  • 49
  • Part of the point of the question was disabling zoom for certain elements, not for the entire page. I'm not even sure I can remember *why* I wanted to do that. I agree with you that there is not sufficient information to catch more than the keystrokes. Thanks for trying, anyway! – Jonathan Morgan Sep 05 '11 at 12:43