javascript - Attempting to simulate a wheel event [Firefox] -
to clarify example, want simulate scroll event @ center of open window. should affect reasonably main scrolling element on given page.
here relevant pages
https://developer.mozilla.org/en-us/docs/web/api/wheelevent/wheelevent
https://developer.mozilla.org/en-us/docs/web/api/mouseevent/mouseevent#values
and here's i've tried.
scroll_evt = new wheelevent('wheel', { deltay: 10.0, deltamode: wheelevent.dom_delta_line, clientx: content.innerwidth/2, clienty: content.innerheight/2 }); -> wheel { target: null, buttons: 0, clientx: 520, clienty: 320, layerx: 0, layery: 0 }
however, despite no errors, dispatching event seems not have effect.
window.dispatchevent(scroll_evt); -> true
so i'm left wonder: there critical property i'm missing in initializer? window
appropriate target event? i'm out of ideas.
update
var windowutils = window.queryinterface(components.interfaces.nsiinterfacerequestor) .getinterface (components.interfaces.nsidomwindowutils); windowutils.sendwheelevent(window.innerwidth / 2, window.innerheight / 2, 0, 10, 0, wheelevent.dom_delta_line, 0, 0, 0, 0);
i'm still curious what's matter dispatchevent
.
you can element position so:
var elem = document.elementfrompoint(content.innerwidth / 2, content.innerheight / 2);
and apply scroll:
elem.scrolltop += 10;
Comments
Post a Comment