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

  • Home
  • SEARCH
  • 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 6531239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:51:13+00:00 2026-05-25T09:51:13+00:00

I come to you with an intersting question. Given position (x,y) in an HTML

  • 0

I come to you with an intersting question.

Given position (x,y) in an HTML document, how can you trigger a focus event on an element at that given position.

The problem translates into is there any way to select the element matching a given position?

Sort of like getElementByPosition?

  • 1 1 Answer
  • 0 Views
  • 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-25T09:51:14+00:00Added an answer on May 25, 2026 at 9:51 am

    The easiest option is to use elementFromPoint:

    var element = document.elementFromPoint(x, y);
    element.focus();
    

    Other than that, you can write your own function. This is what first came to mind – I used it a while back when there was some reason for elementFromPoint not working correctly, I don’t remember what exactly. There are likely to be better ways to do it, but I just tried what I thought of first:

    var coords = [100, 100],
        elems = document.getElementsByTagName("*");
    for(var i = 0; i < elems.length; i++) {
        var left = elems[i].offsetLeft,
            top = elems[i].offsetTop,
            width = elems[i].offsetWidth;
            height = elems[i].offsetHeight;
        if((left <= coords[0]) && (left + width >= coords[0]) && (top <=coords[1]) && (top + height >= coords[1])) {
            elems[i].focus();
        }
    }
    

    You can see it working here.

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

Sidebar

Related Questions

I have recently come across an interesting question on strings. Suppose you are given
I come across this problem when i am writing an event handler in SharePoint.
This is an interesting problem I've come across that I feel should have an
I've come across an interesting problem in the following line of code: <img style=background-image:url(Resources/bar.png);
I've come upon a rather interesting thing, which I can't seem to figure out
Firstly, I realise that this is a very similar question to this one: Which
i have a question on a problem i am working on. I have to
I've come into an interesting problem (as is often the case in interacting with
I was toying around with some of the linq samples that come with LINQPad.
I come from a C++ background where I can use template mixins to write

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.