+ 1
Can i click at specific xy axis in a webpage using javascript
I want to click at a xy axis of a page without mouse but js
2 ответов
+ 2
You cannot.
But you could:
+ trigger a click event on an element
+ get the elements under a coordinate (x,y) of the viewport (window) of a document
https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/elementsFromPoint
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click
Also, you could trigger "manually" any events, so you could simulate your click event by passing a customized event object (showinh fake mouse coordinates):
https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events#Triggering_built-in_events
+ 1
as said visph you cannot force the user to move the cursor at a certain x,y and click.
however, you do this:
<div id='click'><div>
#click {
/* w & h optionnal... */
width: 10px;
height: 10px;
position: absolute;
top: yourY;
left: yourX;
}
document.querySelector('#click').click();