views:

128

answers:

1

Hi i am using

 document.elementFromPoint(x,y);

function to find out the underlying element on the mouse click. It is working fine when i open the corresponding html file with firefox. But i have written an application using gtkmozembed to open html files. When i open html file with my application and clicked on the page it is giving following error:

TypeError: document.elementFromPoint is not a function 

Why it is so? Actually all the functions which works for firefox, also work with gtkmozembed right?(as both firefox and gtkmozembed uses gecko engine internally)

A: 

It is true both Firefox and gtkmozembed use Gecko rendering engine, but versions of engines you are trying your code in may be different, so that the function may be or may be not available.

Worth noticing, it is hardly necessary to use this function in reality - you can approach the problem from the other side - check the event.target property to see where your mouse event was originated.

BTW: document.elementFromPoint function is another example of great yet proprietary technology originated from Internet Explorer. As many other good features it was picked up only recently and implemented by many vendors including Mozilla.

Sergey Ilinsky
yes, event.target does fulfill my requirement.Thank you very much
ganapati
`event.target` is great when responding to user actions. `elementFromPoint()` can be used to find an element (by position) programmatically, I guess that's what it's for.
npup
@npup You are correct, nobody said otherwise. By the way, can you describe a couple of practical use-cases?
Sergey Ilinsky