简体   繁体   中英

htmlEle.fireEvent(“onclick”, document.createEventObject()) doesn't work on IE 11

Hi I have a click event associated with a image button. I am trying to fire the click event by htmlEle.fireEvent("onclick", document.createEventObject()) but i get error object doesn't support property or method 'createEventObject' on IE 11. The click event works perfectly fine for IE 9. Is there a substitute for createEventObject that i can use for IE 11? Thanks

I think createEventObject is not supported in IE 10+ ( source ).

Try using something like this:

var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
myObject.target.dispatchEvent(evt);

as explained here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM