View Full Version : Capturing resize events

09-08-2006, 02:58 PM
How can I detect that browser window is being resized, other than continous loop of checking its dimensions?

I tried window.onresize = runme(), document.onresize = runme(), document.body.onresize = runme() and while it doesn't generate errors, the called function doesn't fire up...

any ideas?

09-08-2006, 03:17 PM
you probably want to go with an event based function that checks only when your window is resized.

If you have programmed with DOM before, you want use event handlers and listeners to set this up.

You could use DOM level 0 event with onResize()


09-08-2006, 03:42 PM
hmmm, let's call it: accidental feature- resize browser window...
and then move the "inner" window...

09-08-2006, 06:39 PM
I tried window.onresize = runme() ...

Unless the runme function returns a function object which is the real listener, lose the parentheses:

window.onresize = runme;

In your post, the runme function would be called when that expression statement is evaluated, and the return value of that function would be assigned to the property and used as the event listener.