How to find what control is in some position?

J

jkarpago

Hi:
I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.
Can anyone help me, please?

Thanks so much.
 
T

Thomas 'PointedEars' Lahn

jkarpago said:
I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.

You will need a bubbling event, then evaluate its event target in its event
listener. If that target is the element on which you are listening for
the event, none of its descendants handled it. Otherwise, the computed
coordinates of the handling descendant indicate its location. This
approach is efficient (AIUI, O(1)) but unprecise insofar that more than
one element can be at that position, and only the topmost element this
event applies to will be identified as event target.

Another more precise approach is to compute the area each element covers,
and then run a comparison for each element, in O(n).

Bottom line:
Describe what you are up to, not what you /think/ you need to know to do it.


PointedEars
 
V

VK

jkarpago said:
Hi:
I need to find what control is in some position given.
I mean, if I give the values left: 200px and top 300px I need to know
what control in the page is in that position, or if there is not any.
Can anyone help me, please?

Thanks so much.

For IE use document.elementFromPoint(x,y) method.

For the Co you need to dig it out manually as suggested.
 
J

jkarpago

Thanks for your help. That´s what I imagine, but I wanted to know if
there was another solution.
Thanks so much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top