Javascript 是否可以使用clientX和clientY在窗口范围内使用vanilla js触发对按钮的单击

Javascript 是否可以使用clientX和clientY在窗口范围内使用vanilla js触发对按钮的单击,javascript,Javascript,提供给我的数据如下: [{"y":69,"x":63,"type":"mousedown","time":1534261731696},{"y":69,"x":63,"type":"mouseup","time":1534261731886,"data":{}}] 如何使用给定的clientX和clientY位置触发click事件存在一个按钮,它附带了onclick处理程序。 我知道我可以获取find元素,然后触发事件,但在提供给我的数据中,没有提供。 我想的另一个选择是,如果有一种方法可以找

提供给我的数据如下:

[{"y":69,"x":63,"type":"mousedown","time":1534261731696},{"y":69,"x":63,"type":"mouseup","time":1534261731886,"data":{}}]
如何使用给定的clientX和clientY位置触发click事件存在一个按钮,它附带了onclick处理程序。 我知道我可以获取find元素,然后触发事件,但在提供给我的数据中,没有提供。 我想的另一个选择是,如果有一种方法可以找到给定x和y的dom元素,如果存在一个按钮,则应用给定的事件

这就是dom所看到的,假设按钮位于x:63,y:69。

以下是我尝试过但没有成功的地方:

//Option 1
    var clickEvent = document.createEvent ('MouseEvents');
          clickEvent.initMouseEvent (event.type, true, true, window, 0, event.x, event.y, event.x, event.y, false, false, false,false, 0, document.parentNode);

    window.dispatchEvent(clickEvent);

//option 2
  let mouseEvent = new Event(event.type, {
        bubbles: true,
        cancelable: true
      });
         mouseEvent.pageX  = event.x;
         mouseEvent.pageY = event.y;
         mouseEvent.view = window;
       window.dispatchEvent(mouseEvent)

您可以使用
document.elementFromPoint(x,y).click()其中x和y是元素的x和y坐标

document.querySelector('button')。addEventListener(“单击”),函数(事件){
警报(“点击”);
});
document.elementFromPoint(8,8).单击()
html,正文{
填充:0;
}

按钮
谢谢,但是我可以使用mouseup和mousedown等事件而不是单击吗?