Page 1 of 1

div position: absolute; ... need to move w/ window.onresize

Posted: Mon Mar 19, 2007 8:16 am
by Kaervek
...and it aint working!

like why wont simply this code work?

Code: Select all

<div align="center" id="moolayer" style="position:absolute; left:0px; top:150px; width:200px; background-color:#0066FF;" window.onresize="MM_changeProp('moolayer','','style.left','500px','DIV')">MOO</div>
this works...

Code: Select all

<div align="center" id="moolayer" style="position:absolute; left:0px; top:150px; width:200px; background-color:#0066FF;" onmouseover="MM_changeProp('moolayer','','style.left','500px','DIV')">MOO</div>

Posted: Mon Mar 19, 2007 9:37 am
by feyd
"window.onresize" is not a valid event for any object but windows.

You need to add your resize event code to the window, not the div.

Posted: Mon Mar 19, 2007 11:00 am
by Kaervek
ok any tips on how i could add the event to the window?

Posted: Mon Mar 19, 2007 11:05 am
by mikeq
put this into Google "window.onresize"
and I guarantee the first link will show you how.

Amazing eh?

Posted: Mon Mar 19, 2007 11:24 am
by Kaervek
dude... iv been scouring google all morning trying to figure this out... i never really searched for exactly window.onresize though, because i was looking for examples of how to position a div.

plus im really not good at javascript yet.

I think I should be able to get this working now tho

Posted: Mon Mar 19, 2007 11:28 am
by Kaervek
hmm
<object>.<event-name> = <function-name>

weird, i havent seen this kind of structure in any other language.

Posted: Mon Mar 19, 2007 11:39 am
by feyd
It stems from the use of function pointers in C.