开发者

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

开发者 https://www.devze.com 2023-03-19 06:37 出处:网络
Does scroll zooming in or out in browser trigger window.resize() event from jquery/jscript? (when you press down on 开发者_如何学编程control and and use you mouse\'s scroll wheel with the browser wind

Does scroll zooming in or out in browser trigger window.resize() event from jquery/jscript? (when you press down on 开发者_如何学编程control and and use you 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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消