Simulate real mouse click

前端 未结 2 1079
挽巷
挽巷 2021-02-19 12:02

What I want to do is execute a mouse click say on youtube to press play when the page loads. How do I click that specific location (assuming it is always in the same location)?<

2条回答
  •  情深已故
    2021-02-19 12:19

    In general, browsers won't let simulated mouse clicks trigger "real" actions, e.g. a jQuery click() won't cause the browser to follow a link. Otherwise, spammers could trigger banner clicks on every page load (among other more malicious uses).

    According to http://www.filosophy.org/2011/03/talking-to-the-web-the-basics-of-html5-speech-input/:

    Eventually, it will be possible to invoke the speech-recognition directly with the startSpeechInput() method, but to my knowledge this is not implemented in any of the current browsers.

    I suggest waiting for Chrome to implement the API so that you can trigger speech input from JavaScript.

提交回复
热议问题