dispatchevent

How to download the current document's innerHTML as a file?

旧巷老猫 提交于 2021-02-18 10:28:25
问题 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 preserve any post-load document modifications . var save = document.createElement('a'); save.href = "my location href.attr"; save.target = '_blank'; save.download = fileName || 'unknown'; var event = document.createEvent('Event'); event.initEvent(

ActionScript 3.0 - Dispatch event class to class

拥有回忆 提交于 2020-01-06 14:38:10
问题 I'm working in Action Script 3.0 and I have a question in DispatchEvent class. following code is standalone class. I want to dispatch event to 'main' class and 'sub' class when event occured. I'm stuck on this issue. please help me. package com { import flash.events.*; import flash.display.MovieClip; import com.sub; public class main extends MovieClip { public static const BTN_CLICKED:String = "btn_Clicked"; public function main():void { if (stage) init(); else addEventListener(Event.ADDED_TO

React.js broke dispatchEvent

六月ゝ 毕业季﹏ 提交于 2020-01-05 05:49:09
问题 for example: I add event handler in react: <div onClick={someHandler}/> Then I dispatch event: let clickEvt = new MouseEvent('click', { 'bubbles': false, 'cancelable': true }); elm.dispatchEvent(clickEvt); But nothing happens. I hear you can use elm.click() to trigger the react event. I'm wondering if that is the proper way to do it in react? Also what is the difference between click() and dispatchEvent() ? Because I kinda want to stick to dispatchEvent() . 回答1: All I figured it out. bubbles

Dispatching keyboard event doesn't work in JavaScript

蹲街弑〆低调 提交于 2020-01-04 05:22:20
问题 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 = document.createEvent("KeyboardEvent"); event.initKeyEvent("keydown", true, true, window, false, false, false, false, 87, 0); document.getElementById("id").dispatchEvent(event); This returns true but the corresponding character doesn't appear in the input. I tried with keypress and

Why firing a defined event with dispatchEvent doesn't obey the bubbling behavior of events?

核能气质少年 提交于 2020-01-01 08:06:39
问题 I'm confused with the script below: var event = new Event('shazam'); document.body.addEventListener('shazam',function(){ alert('body'); }); document.addEventListener('shazam',function(){ alert('document'); }); window.addEventListener('shazam',function(){ alert('window'); }); document.body.dispatchEvent(event); When I run this script on my browser, I just get the alert('body'); event. but if i set the capturing parameter of addEventListener (the third optional parameter) to true, all the

Javascript dispatchEvent click is not working in IE9 and IE10

独自空忆成欢 提交于 2020-01-01 03:50:11
问题 I'm trying to simulate mouse events like click, mouseover etc on app build in ExtJs. I'm using below code to simulate click, function triggerEvent(element, eventName) { if (document.createEvent) { var evt = document.createEvent('MouseEvents'); evt.initEvent(eventName, true, true); return element.dispatchEvent(evt); } } var btn = document.getElementById("loginButton"); triggerEvent(btn, "click"); This works fine on chrome and firefox but never works on IE9 and IE10. If I use btn.fireEvent(

Is it possible to dispatchEvent() a mouse click to a <input type=text> element?

六月ゝ 毕业季﹏ 提交于 2019-12-29 05:06:47
问题 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"); clickEvent.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); var element = document.getElementById(id); element.dispatchEvent(clickEvent); } When I run that code on a type="checkbox" element it works perfectly fine but it doesn't

Canvas handling event, then passing through to iframe…?

天涯浪子 提交于 2019-12-24 22:46:13
问题 Despite searching all evening, I still haven't found a solution to this. I have the following layout in the DOM: <div class="kort_miðja_úti"> <iframe class="kort_miðja" frameborder="0" width="100%" height="100%" src="...."></iframe> <canvas class="kort_canvas"></canvas> </div> The canvas is in front, acting as a transparent overlayer on an interactive map from a different site. So when there's a mouse event, it gets it first. It needs to do things on the mouse events, then forward them on to

dispatchEvent trigger not working on element id

我只是一个虾纸丫 提交于 2019-12-24 19:53:06
问题 I am facing an issue while calling dispatchEvent for addEventListener event. The code is doing exactly what I want, but the difference is that I want to call dispatchEvent on the button id rather than document . function fire( elem, type ) { var evt = elem.createEvent("Events"); evt.initEvent( type, true, true, window, 1); elem.dispatchEvent(evt); } document.addEventListener( "click", function() { console.log( "Fired a synthetic click event" ); }, false ); fire( document, "click" ); I tried

Itemrenderer Dispatch Custom Event

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 02:57:09
问题 I'm trying to dispatch a custom event from a custom ItemRenderer This is my custom event package events { import customClass.Product; import flash.events.Event; public class CopyProductEvent extends Event { public static const COPY_PRODUCT:String = "COPY_PRODUCT"; public var picked:Prodotti; public function CopyProductEvent(type:String, picked:Product) { super(type); this.picked = picked; } } } In the itemRenderer I have a function that does that: private function sendEvent(o:Product):void {