javascript - 如何让JavaScript点击某个位置?

标签 javascript mouseevent mouselistener

我是 JavaScript/HTML 新手。我想知道如何让 JavaScript 点击某个位置。如果不仅使用基本/中级 JavaScript,我会更喜欢它,但也欢迎高级 JavaScript。

最佳答案

是的,这是可能的,并且已经得到解答。请参阅How to simulate a click by using x,y coordinates in JavaScript? :

You can dispatch a click event, though this is not the same as a real click. For instance, it can't be used to trick a cross-domain iframe document into thinking it was clicked.

All modern browsers support document.elementFromPoint and HTMLElement.prototype.click(), since at least IE 6, Firefox 5, any version of Chrome and probably any version of Safari you're likely to care about. It will even follow links and submit forms:

document.elementFromPoint(x, y).click(); https://developer.mozilla.org/En/DOM:document.elementFromPoint https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click

关于javascript - 如何让JavaScript点击某个位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37103727/

相关文章:

java - 在 SWT 中触发鼠标单击事件?

javascript - 服务中的 Angular 存储变量

javascript - 错误跟踪[第 : 42] Le contenu des éléments doit inclure un balisage ou des caractères au format correct 行

javascript - jQuery:如何检测鼠标点击位置是否在div之外

java - 确定最接近鼠标的元素的最有效方法是什么?

java - 将 mouseListener 添加到 JPanel 数组

ruby.none 的 javascript 替代品?

javascript - 如何根据行的内容动态编辑 jqxGrid 中的单元格

css - 更改 "before"行为

jquery - 无法点击用jquery创建的表