Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:56:37+00:00 2026-05-12T17:56:37+00:00

I have the coordinates (X,Y) of a point in an HTML document. How do

  • 0

I have the coordinates (X,Y) of a point in an HTML document. How do I determine what DOM node is at those coordinates?

Some ideas:

  • Is there a DOM hit test function that I missed, that takes a point (X,Y) and returns the DOM element there?
  • Is there an efficient way to walk the DOM element tree to find the containing element? This seems like it would be tricky because of absolutely positioned elements.
  • Is there a way to simulate an event at a given (X,Y) position such that the browser ends up creating an event object that has a pointer to the element?

(Background: I’m embedding Qt’s QWebView in a native application. I’m trying to vary the context menu that the Qt widget provides based on the DOM node that the mouse is over, but Qt 4.5 cannot hit test to a DOM element, though that functionality is coming in 4.6. So I’m hoping I can toss the the coordinate into Javascript and do the hit testing there with DOM APIs.)

Thanks!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:56:37+00:00Added an answer on May 12, 2026 at 5:56 pm

    As long as your users aren’t using old versions of Safari, Chrome or Opera, you’re in luck: use document.elementFromPoint(x, y) (MSDN ref, Mozilla ref, QuirksMode article):

    Returns the element from the document
    … which is the topmost element which
    lies under the given point.

    If you need to support older browsers, I can’t think of many options other than what you suggest (traverse the entire DOM, looking at element positions and sizes and seeing if any of them encapsulate your (x, y)).

    I don’t think the event simulation will work but it is an interesting idea. My understanding of event dispatching is you specify the target that the event is for, which is precisely what you are trying to find out in the first place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use IBM Informix for my project where I have point coordinates
I have coordinates from some source and want to tag my jpg files with
let's say I have some given coordinates x and y for a pixel, how
Have a simple drawing application. The problem is in the coordinates ( redraw function):
In Mathematica I have a list of point coordinates size = 50; points =
I need to have all point coordinates for a given circle one after another,
I have a start point in 3D coordinates, e.g. (0,0,0). I have the direction
Some of the Graphics2D methods, such as drawString , have versions that take coordinates
I have the coordinates of the top left point of a rectangle as well
I have the coordinates of three points on a plane. Let's call them X1,Y1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.