JavaScript window resize event

前端 未结 13 767
余生分开走
余生分开走 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:09

    The following blog post may be useful to you: Fixing the window resize event in IE

    It provides this code:

    Sys.Application.add_load(function(sender, args) {
        $addHandler(window, 'resize', window_resize);
    });
    
    var resizeTimeoutId;
    
    function window_resize(e) {
         window.clearTimeout(resizeTimeoutId);
         resizeTimeoutId = window.setTimeout('doResizeCode();', 10);
    }
    

提交回复
热议问题