javascript simulate mouse click on specific position

末鹿安然 提交于 2019-12-06 00:41:37

If all you want to do is click a button, button elements have a click method that can be invoked:

<input type="button" id="theButton" onclick="javascript:alert('The button was clicked!');" value="A button" />

<script language="javascript">

setTimeout(function(){
    document.getElementById("theButton").click();
}, 1000); // wait one second then click the button

</script>

There's no need to "actually" simulate the mouse click at a specific x,y position.

I dont know if its posible to do that on javascript but if you need automatic and periodic clicks maybe you can do that with external tools like autohotkey

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!