JavaScript 中的 PHP 和 window.close

编程入门 行业动态 更新时间:2024-10-25 14:22:37
本文介绍了JavaScript 中的 PHP 和 window.close的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有问题.我有一个页面,当您单击按钮时,会显示一个带有表单的弹出窗口.所以,我完成了一些数据并提交.我想要做的是,提交表单,关闭表单并刷新父页面.我不想用 AJAX 来做.

I have a problem. I have a page that when you click a button, a popup with a form is shown. So, I complete some data and I submit. What I want to do is, to submit the form, close the form and refresh the parent page. I don't want to do it with AJAX.

问题是在我的父页面中,我必须使用表单的输入信息刷新内容.

The problem is that in my parent page I have to refresh content with the input information of the form.

所以当我刷新时,有时会显示数据,有时不会.你知道为什么会发生这种情况吗?

So when I refresh, sometimes the data is shown and sometimes not. Do you know why this could happen?

我只是在表单中使用 onsubmit="refreshParent()".信息总是存储在我的数据库中,所以我认为问题可能是有时刷新会捕获新信息,有时不会.

I just use onsubmit="refreshParent()" in my form. The info is stored always in my database, so I think the problem may be that sometimes the refresh catches the new info and sometimes not.

function refreshParent() { window.opener.location.reload(); window.close(); }

推荐答案

我用它来重新加载打开弹出窗口的页面:

I use this to reload the page that opened a popup window:

<script language="JavaScript"> <!-- function reloadParentPage() { window.opener.location.href = window.opener.location.href; if (window.opener.progressWindow) { window.opener.progressWindow.close() } window.close(); } //--> </script>

顺便说一下,上面的代码是通过弹出页面中的链接或按钮调用的.

By the way, the code above is called by a link or button in the popup page.

更多推荐

JavaScript 中的 PHP 和 window.close

本文发布于:2023-11-09 15:33:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PHP   JavaScript   close   window

发布评论

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

>www.elefans.com

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