davidklonski
07-08-2004, 02:29 PM
Hello
I wrote a function which will find the exact top left coordinates in the screen.
The function will return an associative array with information on the element:
function getPositionAndDimension(element) {
var left = 0;
var top = 0;
var width = element.offsetWidth;
var height = element.offsetHeight;
while (element.parentElement != null) {
left += element.offsetLeft;
top += element.offsetTop;
element = element.parentElement;
}
var results = new Array(4);
results['left'] = left;
results['top'] = top;
results['width'] = width;
results['height'] = height;
return results;
}
The problem is that the value that the function calculates for the element's top is incorrect.
I am getting values that are much larger than the actual top value.
can anyone see where the bug is in?
I am testing this on IE6
thanks
I wrote a function which will find the exact top left coordinates in the screen.
The function will return an associative array with information on the element:
function getPositionAndDimension(element) {
var left = 0;
var top = 0;
var width = element.offsetWidth;
var height = element.offsetHeight;
while (element.parentElement != null) {
left += element.offsetLeft;
top += element.offsetTop;
element = element.parentElement;
}
var results = new Array(4);
results['left'] = left;
results['top'] = top;
results['width'] = width;
results['height'] = height;
return results;
}
The problem is that the value that the function calculates for the element's top is incorrect.
I am getting values that are much larger than the actual top value.
can anyone see where the bug is in?
I am testing this on IE6
thanks