Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

internet explorer 11 - 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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...