关闭弹出窗口时如何刷新页面..?

编程入门 行业动态 更新时间:2024-10-09 21:18:11
本文介绍了关闭弹出窗口时如何刷新页面..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

关闭弹出窗口时如何刷新页面.. 看到我的代码 ------------- < a href =#" onclick ="window.close();" class ="Content">关闭窗口</a> 我想在关闭弹出窗口时立即刷新或重新加载父窗体..

Hi, How to refresh the page when i close the popup window..? see my code ------------- <a href="#" onclick="window.close();" class="Content">Close Window</a> I want, when i close the popup window, immediately the parent form should get refresh or reload.. How to do this...?

推荐答案

有几种方法,但一种简单的方法可能是 There are several ways but one simple way could be function closeandrefresh(){ opener.location.href = opener.location.href; window.close(); }

并将您的链接更新为 < a href =#" onclick ="closeandrefresh();" class ="Content">关闭窗口</a>

And update your link as <a href="#" onclick="closeandrefresh();" class="Content">Close Window</a>

亲爱的可以通过AJAX ............ Dear it is possible through AJAX............

您可以在父窗口中使用递归函数来等待弹出窗口关闭.例如 You can use a recursive function in the parent window to wait for the popup to close. E.g. <html> <head> <script type="text/javascript">

var generator = null; function show_prompt() { //Open a popup and store the handler in a var named generator generator = window.open("", "New Popup", "width=400, height=400"); //Add some html to the new window generator.document.write("<html><head><title>Test</title></head><body>"); generator.document.write("<p><a href=\"javascript:self.close()\"> Close</a></p>"); generator.document.write("</body></html>"); generator.document.close(); generator.focus(); //The crucial line! Start the recursive function that will poll the new popup window until it's closed. WaitForClose(); } function WaitForClose() { //Check to see if the popup has been closed if(!generator.closed) { //If not, recall this function - the recursion setTimeout("WaitForClose()", 500); } else { //If popup has been closed, call the PopupClosed funtion PopupClosed(); } } function PopupClosed() { //Do something here! alert("x"); }

</script> </head> <body> <input type="button" onclick="show_prompt()" value="Show prompt box" /> </body> </html>

希望这会有所帮助, 埃德:)

Hope this helps, Ed :)

更多推荐

关闭弹出窗口时如何刷新页面..?

本文发布于:2023-08-06 11:25:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1311963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:弹出窗口   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!