Stickybomb Posted March 26, 2007 Share Posted March 26, 2007 i am working on a script to make a div move around on the sceen when you mouse over an image for some reason i cant get it to work i think i have a DOM issue but not sure here is the code i am using. onmouseover="document.families-head.style.top='500px'; i have a similar out call that moves the div back. both of which are being from an image. if anyone could assist me with this it would help alot thks! Link to comment https://forums.phpfreaks.com/topic/44390-contoling-position-with-javascript/ Share on other sites More sharing options...
mainewoods Posted March 27, 2007 Share Posted March 27, 2007 What is 'families-head'? Is that the id= of the div? If so then do this: onmouseover="document.getElementById('families-head').style.top = '500px';" Link to comment https://forums.phpfreaks.com/topic/44390-contoling-position-with-javascript/#findComment-216132 Share on other sites More sharing options...
BlackenedSky Posted March 28, 2007 Share Posted March 28, 2007 change the position of the element using element.style.top or element.style.left in firefox, but in IE use element.offsetTop and element.offsetLeft unless the element is positioned absolutely. no harm in using both to make sure Link to comment https://forums.phpfreaks.com/topic/44390-contoling-position-with-javascript/#findComment-216983 Share on other sites More sharing options...
mainewoods Posted March 28, 2007 Share Posted March 28, 2007 in ie, you might want to leave off the 'px': onmouseover="document.getElementById('families-head').style.top = '500';" Link to comment https://forums.phpfreaks.com/topic/44390-contoling-position-with-javascript/#findComment-217078 Share on other sites More sharing options...
BlackenedSky Posted March 29, 2007 Share Posted March 29, 2007 in ie, you might want to leave off the 'px': onmouseover="document.getElementById('families-head').style.top = '500';" or use: onmouseover="document.getElementById('families-head').style.top = 500 + 'px';" Link to comment https://forums.phpfreaks.com/topic/44390-contoling-position-with-javascript/#findComment-217665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.