in reply to Re^6: Position on Web Page
in thread Position on Web Page
function findPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
while(1)
{
curleft += obj.offsetLeft;
if(!obj.offsetParent)
break;
obj = obj.offsetParent;
}
else if(obj.x)
curleft += obj.x;
return curleft;
}
Basically it keeps adding all the left offsets for the parent nodes until i reach the top. Is this alright? Once i get that I can only approsimately get the right position. Say the node is 'p tag'. Then it could have lots of text which will eventually resize. So i can get my arrow somewhere in 'p tag' for sure. But what about the location in that.
If you resize this browser window, you will see that the text above that i have written will readjust too. However the smallest dom node returned will be 'p tag' for the above text. I can get using dom the location of p tag but how can i maintin the position of the arrow within that 'p tag' tag so that it points to the same word? or will it always be approximate?
Also, if I have a node which I have got using event object, can I store it in some form (like offset from root etc...) so that I can retrieve it at a later stage (e.g. when I revisit the page, I will use perl to place the arrow over there but for that i need to know the node which I had clicked earlier). Is there anyway to store the node information so that I can retrieve it later?
Thank you for your time and effort.
Anant
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Position on Web Page
by erroneousBollock (Curate) on Aug 20, 2007 at 16:11 UTC | |
by user2000 (Sexton) on Aug 21, 2007 at 17:30 UTC | |
by erroneousBollock (Curate) on Aug 22, 2007 at 04:19 UTC | |
|
Re^8: Position on Web Page
by erroneousBollock (Curate) on Aug 20, 2007 at 16:20 UTC |