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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Kaervek
Forum Commoner
Posts: 25
Joined: Fri Jul 08, 2005 7:17 am
Location: Newfoundland
Contact:

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

Post 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>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Kaervek
Forum Commoner
Posts: 25
Joined: Fri Jul 08, 2005 7:17 am
Location: Newfoundland
Contact:

Post by Kaervek »

ok any tips on how i could add the event to the window?
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

put this into Google "window.onresize"
and I guarantee the first link will show you how.

Amazing eh?
Kaervek
Forum Commoner
Posts: 25
Joined: Fri Jul 08, 2005 7:17 am
Location: Newfoundland
Contact:

Post 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
Kaervek
Forum Commoner
Posts: 25
Joined: Fri Jul 08, 2005 7:17 am
Location: Newfoundland
Contact:

Post by Kaervek »

hmm
<object>.<event-name> = <function-name>

weird, i havent seen this kind of structure in any other language.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It stems from the use of function pointers in C.
Post Reply