could not get element position in a frame.. |
could not get element position in a frame.. |
kuppi |
Nov 12 2008, 02:16 AM
Post
#1
|
Group: Members Posts: 4 Joined: 6-November 08 Member No.: 7,060 |
I am working on javascript.
I have a frame in which I have many elements(actually they are images). when I select an element using mouse and then try to navigate down/up using arrow keys(from keyboard), scrollbar should move accordingly. The element which we have selected should be visible. This is working fine in Mozilla(Firefox.). This is not working in IE(I am using IE8). I tried to find the element location(offset values of element) in the window and move scrollbar to respective position. Below is the function in which I tried to find element location. function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { curleft = obj.offsetLeft curtop = obj.offsetTop while (obj = obj.offsetParent) { curleft += obj.offsetLeft curtop += obj.offsetTop } } return [curleft,curtop]; } But I am not able to get offsetLeft/offsetTop/offsetParent values(in Mozilla and IE). Can you please tell me if I have gone wrong some where? if there is any other way to get element position, please guide me. |
Lo-Fi Version | Time is now: 19th April 2024 - 06:47 PM |