Questions tagged [dispatchevent]
170 questions
68
votes
4 answers
dispatchEvent in Chrome but not in IE11
I am using the following code to submit to a form:
element.dispatchEvent(new Event("submit"));
Inspector returns the error:
Object doesn't support this action
This works in Chrome.
The purpose of this command is to make a division call the submit…
user4014674
58
votes
6 answers
"element.dispatchEvent is not a function" js error caught in firebug of FF3.0
i am getting the following error while loading my index page in FF3.0. Sorry, i am unable to paste the script here as it is 2030 lines of code.
element.dispatchEvent is not a function
On expansion it gives me below things,
fire()()prototype.js?1…

Subh
- 601
- 2
- 6
- 5
22
votes
1 answer
Why firing a defined event with dispatchEvent doesn't obey the bubbling behavior of events?
I'm confused with the script below:
var event = new Event('shazam');
document.body.addEventListener('shazam',function(){
alert('body');
});
document.addEventListener('shazam',function(){
…

Shnd
- 1,846
- 19
- 35
20
votes
1 answer
How to fire mouse wheel event in Firefox with JavaScript?
I'm trying to do automated testing with WebDriver, but it currently has no ability to simulate mouse wheel events. As a workaround I'm trying to fire these events with JavaScript instead. I'm doing all my wheel experimenting on a straight HTML…

Justin Aquadro
- 2,280
- 3
- 21
- 31
17
votes
1 answer
Is it possible to dispatchEvent() a mouse click to a element?
Basically I'm trying to dispatch a custom made mouse click event to a text input element using the following code (see this jsFiddle):
function simulateClick(id) {
var clickEvent = document.createEvent("MouseEvents");
…

Philip Kamenarsky
- 2,757
- 2
- 24
- 30
11
votes
1 answer
How to properly initialize an ErrorEvent in javascript?
I need to fire an ErrorEvent programmatically, but can't figure out how to initialize the properties of the event. The properties are readonly, and initEvent() only initializes the event type, whether it bubbles, and if it's cancellable.
I tried
var…

sboisse
- 4,860
- 3
- 37
- 48
10
votes
1 answer
How to download the current document's innerHTML as a file?
Is there a way I could download the current document's innerHTML as file programmatically?
I've made the following attempt without success. It does download the current document's source, however that's not what I am looking for, since I want to…

saeedhbi
- 350
- 4
- 17
9
votes
3 answers
How to dispatch an event with added data - AS3
Can any one give me a simple example on how to dispatch an event in actionscript3 with an object attached to it, like
dispatchEvent( new Event(GOT_RESULT,result));
Here result is an object that I want to pass along with the event.

user1022521
- 509
- 3
- 9
- 16
8
votes
1 answer
Leaflet JS - Implementing Gesture Handling to enforce 2 fingered scrolling
You know when you're on a mobile device and you scroll down a web page which has a google map. The map goes dark and tells you "Use two fingers to move the map".
I want to implement exactly this in my Leaflet map. Leaflet doesn't currently offer…

elMarquis
- 7,450
- 4
- 38
- 42
8
votes
2 answers
What are the difference between postMessage() and dispatchEvent() in respect to the origin policy?
I have this code, I have set the MessageEvent 's origin to *, but still the console prompts Blocked a frame with origin "AAAA" from accessing a frame with origin "BBBB". Protocols, domains, and ports must match. Anyone know why?
var size = {
…

Blake
- 7,367
- 19
- 54
- 80
6
votes
1 answer
"Run all cells" command in Google Colab programmatically
I need to run certain command "Run all" from Google Colab menu "Runtime" programmatically. It does not have any obvious "onclick" eventHandler which I could call from javascript code on that page.
Other "divs" on the page are OK to be called from…

Sergeika Uarabeika
- 63
- 1
- 4
6
votes
1 answer
dispatchEvent(new Proxy(event, {}) does not work
I'm working on an app which uses events. The modules of the app execute in separate containers and I thought about using Proxy to tame the events that are fired. However, I cannot seem to be able to make dispatchEvent accept an event that has been…

user253530
- 2,583
- 13
- 44
- 61
6
votes
2 answers
Uncaught InvalidStateError: Failed to execute 'dispatchEvent' on 'EventTarget': The event provided is null
I am getting weird behavior where Javascript event that I am trying to dispatch is not being interpreted as event while when I inspect it is is Event.
Then it fails with following error:
Uncaught InvalidStateError: Failed to execute…

Matas Vaitkevicius
- 58,075
- 31
- 238
- 265
6
votes
3 answers
Dispatch MouseEvent
Is there a way to dispatch MouseEvent, same as dispatchKeyEvent using the
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(listener);
that happens before the event transferred to the component ?
I know I have 2 options…

shay
- 1,317
- 4
- 23
- 35
6
votes
1 answer
Dispatching keyboard event doesn't work in JavaScript
I'm trying to simulate user input in browser with JavaScript. Click events are created and dispatched successfully but for some reasons a similar code for keyboard events doesn't seem to work at all.
var event =…

John Doe
- 405
- 3
- 16