JavaScript window resize event

前端 未结 13 783
余生分开走
余生分开走 2020-11-22 00:58

How can I hook into a browser window resize event?

There\'s a jQuery way of listening for resize events but I would prefer not to bring it into my project for just t

13条回答
  •  长情又很酷
    2020-11-22 01:03

    jQuery is just wrapping the standard resize DOM event, eg.

    window.onresize = function(event) {
        ...
    };
    

    jQuery may do some work to ensure that the resize event gets fired consistently in all browsers, but I'm not sure if any of the browsers differ, but I'd encourage you to test in Firefox, Safari, and IE.

提交回复
热议问题