I have a function which finds the x and y coordinate of any object in
the document by referring to offsetLeft or offsetTop value of the
object's offsetParent, all the way to the top of the DOM, i.e.:
function get_y(obj) {
var coord = 0;
while (obj.offsetParent) {
coord += obj.offsetTop;
obj = obj.offsetParent;
}
return coord;
}
function get_x(obj) {
/* same as above function, but with offsetLeft in place of offsetTop
*/
}
Now, I've tested this function out many, many times on documents built
using table models, and it works perfectly. However, I tried to import
the same function to a document using a CSS model without any tables
and it fails on the y-coord function ONLY -- the x-coord function
(offsetLeft) works just as it would on a document using the table
model, but the y-coord function produces the following error in a CSS
model:
"Line 0: Error parsing value for property 'top'; Declaration dropped"
(moz error -- IE returns "Invalid argument Line 0")
I'm unable to figure out what the problem is. I'm assuming I've left
out a certain required parameter in my stylesheet, but I don't know
what it could be!
Any insight would be appreciated!