Javascript 从 jquery 对话框刷新父页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1974499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 22:11:25  来源:igfitidea点击:

refresh parent page from jquery dialog

javascriptjqueryjquery-ui

提问by Dejan.S

I want to refresh the parent page when I close my jQuery dialog.

我想在关闭 jQuery 对话框时刷新父页面。

this is the code I use for my dialog. I tried top.opener.locationbut it did not do nothing but put me on top of the page.

这是我用于对话框的代码。我试过了,top.opener.location但它什么也没做,只是把我放在了页面的顶部。

$("#dialog").dialog({ 
    height: 700, 
    width: 600, 
    closeOnEscape: true, 
    title: 'View', 
    close: function(event, ui){ 
        top.opener.location.reload(true); 
    }
}).dialog("open");

回答by Kobi

The jQuery dialog opens on the same page, not in a new window. So simple refresh the current page:

jQuery 对话框在同一页面上打开,而不是在新窗口中打开。如此简单的刷新当前页面:

location.reload(true);