Search code examples
internet-explorer-11childwindow

Why I can't set global variable to child window in IE11?


I am trying to do new functionality. I was able to achieve what I want in modern browsers but not in the IE11.

  if (!window.IS_PRESENTING) {
      childWindow = window.open(window.location.pathname);
      childWindow.IS_PRESENTING = true;
      setupMainWindow();
    } else {
      setupChildWindow();
    }

In modern browsers IS_PRESENTING is being set on the child windows. But in the IE11 it doesnt work and the browser keeps opening new windows...

How can I fix this? Any suggestions?


Solution

  • I can reproduce the issue in IE 11. As a workaround, in IE 11, you can get the value of window.IS_PRESENTING in the opening window and set the opening window's IS_PRESENTING value according to it :

    In the opening window:

    targetWindow = window.opener;
    var IS_PRESENTING = !targetWindow.IS_PRESENTING;  //targetWindow.IS_PRESENTING can get the value of window.IS_PRESENTING in child window
    alert("The value of IS_PRESENTING is " + IS_PRESENTING);
    

    Reference link: Window.opener