我是 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/