window.opener alternatives

前端 未结 5 1844
生来不讨喜
生来不讨喜 2020-11-30 03:39

I am opening a modal popup window. Then I access a parent window textbox and other attributes using window.opener. It is working fine in firefox but not in IE8.

5条回答
  •  星月不相逢
    2020-11-30 04:05

    As a cross-browser alternative, you can give a custom attribute to the new window while you are opening it:

    var popup = window.open(...);
    popup.isPopup = true;
    

    Then, in the referred page:

    if (window.isPopup) {
      // Do something
    }
    else {
      // Not in a popup
    }
    

提交回复
热议问题