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 136581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:58:16+00:00 2026-05-11T06:58:16+00:00

how can simulate an onclick event on a DIV passing only X,Y coordinates??? If

  • 0

how can simulate an onclick event on a DIV passing only X,Y coordinates???

If I try to make that obviously the dispatchEvent function wants the object on which the event will be raised…but then what is the meaning of passing in event creation the coordinates????

Thanks

  • 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. 2026-05-11T06:58:16+00:00Added an answer on May 11, 2026 at 6:58 am

    The clientX and clientY parameters are the position relative to the element handling the event, so you need to know what element the click event is going to.

    If you want to simulate a click to an unknown element based on window coordinates, you will need to find the element at that position. In IE and Firefox 3, you can use document.elementFromPoint(x, y). I don’t know of any way in other browsers, except looping through the elements in the page, looking at their position/size to determine what’s at the coordinates.

    Your code would look kind of like this:

    function simulateClick(x, y) {     var el = getElementFromPoint(x, y);      var evt = document.createEvent('MouseEvents');     evt.initMouseEvent('click', true, true, window,         1, 0, 0,         calculateClientX(el, x), calculateClientY(el, y),         false, false, false, false, 0, null);      el.dispatchEvent(evt); } 

    getElementFromPoint would use either document.elementFromPoint or iterate over all the elements. calculateClientX/Y would calculate the click coordinates relative to the element.

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

Sidebar

Related Questions

I've searched and discovered that I can simulate a keypress event using jQuery, but
Does anyone know of a class/library/etc. that can simulate 32 bit unsigned integers on
Anyone know any softwares that can simulate human interaction on desktop browser specifically by
I've been looking around for a good web automator (something that can simulate a
I have the following: <textarea id=text></textarea> <textarea id=simulator></textarea> <br/> <div onclick=simulate()>Simulate</div> keyslog = [];
Is there a dev aid that can simulate Windows AD on a non-domain machine,
Is there a framework that is compatible with JDK 1.4 that can simulate the
So far, I know that in Rails I can simulate a PUT request using
Are there any possibility to do something like that? Or how I can simulate
I recently came across Linsched where one can simulate in user-space some of the

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.