开发者

popup not closing

开发者 https://www.devze.com 2023-03-02 12:00 出处:网络
I am returning an array to the parent from my popup. It all works fine but the popup doesn\'t close. I even tried window.close

I am returning an array to the parent from my popup. It all works fine but the popup doesn't close. I even tried window.close

function btnClick() 
{
    var myVal = $("input#hdnName").val();
    var myVal1 = $("input#hid").val();
    var myarray = new Array(myVal, myVal1);       
    win开发者_如何学JAVAdow.parent.closeDialog(myarray);
    window.close();
        }


By security reasons, browsers only accepts window.close() if that window was opened by a window.open() on the same context.

In your case, I think the problem is that the window.close() is called by the iframe but it isn't in the same context that opened the popup.

You can try:

  • A popup without the iframe inside.
  • Or better, don't use popups. Use a div floating over your main page, displaying the iframe inside. In fact, there are many jQuery plugins that can do it.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号