Fix mouse click error on IE11

MouseEvent initialization was failing on IE11.
Add a separate case for IE11 that fixes the issue.

Signed-off-by: Ivana Yovcheva <iyovcheva@vmware.com>
This commit is contained in:
Ivana Yovcheva 2018-03-19 18:09:47 +02:00 committed by Alex Ellis
parent 0f126ce241
commit c633fbb96d

View File

@ -96,11 +96,30 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
linkElement.setAttribute('href', url);
linkElement.setAttribute("download", filename);
var clickEvent = new MouseEvent("click", {
var clickEvent;
if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) { // for IE 11
clickEvent = document.createEvent("MouseEvent");
clickEvent.initMouseEvent("click", /* eventName */
true, /* bubbles */
false, /* cancelable */
window, /* view */
0,0,0,0,0, /* detail, screenX, screenY, clientX, clientY */
false, /* ctrlKey */
false, /* altKey */
false, /* shiftKey */
false, /* metaKey */
0, /* button */
null /* relatedTarget */
);
} else {
clickEvent = new MouseEvent("click", {
"view": window,
"bubbles": true,
"cancelable": false
});
}
linkElement.dispatchEvent(clickEvent);
} catch (ex) {
caught = ex;