javascriptjqueryhtmlbrowser

Does scroll zooming in or out in browser trigger window.resize()?


Does scroll zooming in or out in the browser trigger window.resize() event from jquery/jscript? (when you press down on control and use your mouse's scroll wheel with the browser window focused)

EDIT: IF I doesn't as the great answer proves it doesn't; what event is available?


Solution

  • No, it doesn't. Try setting up a page containing this code:

    <script type="text/javascript">
    window.onresize = function(){ alert("resize called"); }
    </script>
    

    Then resize with control + scroll wheel. It won't alert you.

    EDIT: I'd actually use console.log() rather than alert() if you have Firebug/Dragonfly/Chrome Developer Tools or similar.

    EDIT 2:

    Okay, I looked into this further, and I was wrong. The onresize event DOES fire when the page is zoomed. I've just tested in FF 5, Chrome 12, Opera 11.1, and IE 8, and they all work.

    However, there are two caveats:

    1. It won't work on older browsers.
    2. In Firefox, it won't be called if the user has selected the "zoom text only" option.

    That second point is the reason that I didn't catch this earlier. I customarily disable full-page zooming in Firefox.

    So whether this will work depends on how up-to-date your users' browsers are. Check your analytics to see if you have an acceptable majority. And what are you using this for, anyway?