Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate mousedown or keypress event programmatically?

I am developing a chrome extension that runs some javascript on a particular web page.

I want to simulate a click action on the google docs presentation view page's 'prev', 'next' toolbar. Unfortunately, both are tags with onmousedown events corresponding to obfuscated javascript.

If they were anchors, document.getElementById("ToolbarNext").onclick(); works. However, the same for onmousedown does not seem to work, probably because it requires mouse co-ordinates, etc. How do I generate this event?

An other option is to simulate a keypress 'j' or 'k' on the DOM. I tried a few options but could not figure that out either.

like image 336
Arindam Avatar asked May 16 '11 21:05

Arindam


1 Answers

try dispatchEvent/fireEvent methods

like image 188
DrStrangeLove Avatar answered Sep 20 '22 23:09

DrStrangeLove