How to disconnect JavaScript popup from opener

后端 未结 2 562
生来不讨喜
生来不讨喜 2020-12-16 19:11

I\'m opening a popup from my main page with code like this:



        
2条回答
  •  臣服心动
    2020-12-16 19:39

    If the page in the child window is in your control, you can assign null to the opener in the child page:

    window.opener = null;
    

    By making this as the first statement in your javascript.

    If the page is not in your control or is in a different domain, then do it while opening:

    popup = window.open(this.href, '_blank', 'width=512,height=512,left=200,top=100');
    popup.opener = null;
    

提交回复
热议问题