View Full Version : Getting the x/y of any div...
Luckyrare
07-05-2007, 07:36 PM
Is there a way of getting the x/y of any div using javascript? Could anyone link me to a tutorial or code me something quickly.
Thanks
Danny
Invent
07-05-2007, 07:41 PM
http://habboxforum.com/showthread.php?t=343102&page=2
Luckyrare
07-05-2007, 07:46 PM
Doesnt work on Firefox, sadly.
Sygon..
07-05-2007, 08:53 PM
Meh i found this but it seems like a lousy way of doing it:
http://www.howtocreate.co.uk/emails/DavidBerman.html
Mentor
07-05-2007, 09:10 PM
Its easy to do via the DOM. How are you positioning the div to stat with though? Absoulte? relative? etc?
If by css you may use for example.
<style>
#box {
position:absolute;
left:50px;
top:20px;
}
</style>
<div id="box"></div>
You could get the values by.
topval = document.getElementById('box').style.top;
leftval = document.getElementById('box').style.left;
Romanity
08-05-2007, 05:14 PM
Using your method Entor, how would you then go on to echo out the values?
Mentor
09-05-2007, 01:03 AM
Youd use js to take data to and from the page and the php script.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.