Is it me? Is it my IE? or why is this code not working on IE 11:
var clicker = new MouseEvent(\"click\", {
\'bubbles\': true,
\'cancelable\': true,
\'v
The MSDN documentation from the link you provided indicates that the new syntax for the DOM L4 event constructor pattern:
Applies to Internet Explorer for Windows 10 Technical Preview and later.
which is a different version of IE from what you are using. So it's expected that IE11 does not support this feature
Yet another option would be to utilize MDN polyfills package
Installation
npm i mdn-polyfills --save
Usage
import 'mdn-polyfills/MouseEvent';
const link = document.createElement("a");
link.download = fileName;
link.href = url;
link.dispatchEvent(new MouseEvent("click", {bubbles: true, cancelable: true, view: window}));
There is a polyfill to make it work in IE.
Except that the try catch
block in that code needs to look like this:
try {
new CustomEvent('test');
return false; // No need to polyfill
} catch (e) {
// Need to polyfill - fall through
}
I submitted this correction to their website.