DOM onresize event

前端 未结 7 569
无人共我
无人共我 2020-12-02 19:06

If I have this

window.onresize = function() {
  alert(\'resized!!\');
};

My function gets fired multiple times throughout the res

7条回答
  •  长情又很酷
    2020-12-02 19:31

    You get multiple events because there really are multiple events. Windows animates the resize by doing it several times as you drag the window (by default, you can change it in the registry I think).

    What you could do is add a delay. Do a clearTimeout, setTimout(myResize,1000) every time the IE event fires. Then, only the last one will do the actual resize.

提交回复
热议问题