[Greasemonkey] Calling a page-defined function
Joe la Poutre
jsixpack at gmail.com
Mon Aug 14 13:40:43 EDT 2006
On 8/14/06, Gary Tyler <pile0nades at gmail.com> wrote:
[...]
> I also tried to fire the onclick event that zooms in, but I can't find the
> method to fire it.
>
> var deviation = get("span[@id='zoomed-out']/a");
> deviation.click();
>
> This does not work. How do you fire an element's onclick event? Or, get to
> Deviation.zoomIn() without using unsafeWindow?
You can dispatch a click event in the following way:
var clickElement = document.getElementById('someId);
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
clickElement.dispatchEvent(evt);
HTH!
More information about the Greasemonkey
mailing list