0

I want to subscribe to the close / beforeunloadevent of a window:

 public OpenParameters() {

            if (this.openProcessStrategyWindowHandle) {
                this.openProcessStrategyWindowHandle.focus();
            }

            if (this.openParametersWindowHandle) {
                this.openParametersWindowHandle.focus();
                return;
            }

            this.generateUrlParametersWindow();
            this.openParametersWindowHandle = this.$window.open(this.openParametersUrl + "?"
                + this.eveUtilsService.createGuid(),
                "parametersWindow", "width=1280,height=750,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes");
            // event for closing window/tab
            this.openParametersWindowHandle.onbeforeunload = () => {
                this.CloseParametersInfo();
            };
        }

This works fine with Chrome but not with IE11 I also tried subscribing via

this.openParametersWindowHandle.addEventListener("beforeunload", () => {
                this.CloseParametersInfo();
            });

which results on IE in following message: "Das Object untersützt die Funktion oder Eigenschaft "addEventListener" nicht"

I found a might related topic On IE9, Win 7 window.open() returns null instead of reference of the opened window

but none of the suggested fixes helped. any ideas?

Update: what confuses: after setting and hitting a breakpoint in the code above, the code seems to work.

yBother
  • 648
  • 6
  • 25
  • See: https://stackoverflow.com/questions/276660/how-can-i-override-the-onbeforeunload-dialog-and-replace-it-with-my-own – Diodeus - James MacFarlane Jan 08 '19 at 16:14
  • I am sorry but I cannot see any solution in the linked topic. I still don't see any possiblity to subscribe to close event on IE. The accepted answer is exactly what I have tryed but it does not work in IE11. The problem seems to be before that acutally. Somehow IE11 doest not manage to get a proper window reference object. – yBother Jan 08 '19 at 17:11

0 Answers0