PDA

View Full Version : Capturing resize events



ItsMeOnly
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?

sandman
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()

http://www.w3schools.com/htmldom/dom_obj_document.asp

ItsMeOnly
09-08-2006, 03:42 PM
http://rambo.id.uw.edu.pl/pic.php,Critters/Butterflies/Noctuidae/Catocala+nupta+1.jpg,viewer,0,0
hmmm, let's call it: accidental feature- resize browser window...
and then move the "inner" window...

mwinter
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.

Mike