Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 108
    This should have been the accepted answer. Overriding onresize is just bad practice. Commented Jun 11, 2012 at 10:05
  • 11
    hah, what's with all the extra null checks? trying to work in IE 4.5 or something? Commented Sep 15, 2012 at 4:24
  • 2
    And you are wondering how do I call this function to receive window resize events? Here is how: addEvent(window, "resize", function_reference); :) Commented Feb 20, 2014 at 17:28
  • 6
    Note that as of IE 11, attachEvent is no longer supported. The preferred way for the future is addEventListener. Commented Feb 26, 2014 at 23:26
  • 6
    Be careful with elem == undefined. It is possible (although unlikely) that "undefined" is locally defined as something else. stackoverflow.com/questions/8175673/… Commented Feb 26, 2014 at 23:39