简体   繁体   English

关闭弹出并刷新父页面javascript

[英]Close pop up and refresh parent page javascript

i want to close pop up and refresh parent but after few seconds delay to make sure all data is received. 我想关闭弹出窗口并刷新父项,但要延迟几秒钟以确保接收到所有数据。 currently i have the following 目前我有以下

function closeAndRefresh(){    
  setTimeout(function()
 {     
window.open('/{!currSubId}','_top');
window.location = window.location.href;
return true;
},5000)}

This code refreshes the parent but inside the popup, so the pop up does not close, rather the parent shows refreshed - in pop up 这段代码刷新了父级,但在弹出窗口内部,因此弹出窗口不会关闭,而是父级显示刷新了-在弹出窗口中

So move the pop up outside of the timeout, give it a name, call close, and reload. 因此,将弹出窗口移出超时,给它命名,关闭并重新加载。

function closeAndRefresh(){    
    var winPop = window.open('/{!currSubId}','_top');  //load pop up give it a name
    window.setTimeout(function(){
        winPop.close();  //close pop up
        window.location.reload(true);  //refresh current page
    },5000);
}

You could just use an Ajax call to the server and not have to deal with a pop up and wondering if the pop up blocker will block it or not knowing if the call completetd. 您可以只使用对服务器的Ajax调用,而不必处理弹出窗口,并且想知道弹出窗口阻止程序是否将阻止它,或者不知道调用是否完成。 When the call comes back from the call, you can just reload the page. 当呼叫从呼叫返回时,您只需重新加载页面即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM