繁体   English   中英

重新加载浏览器时重新打开的弹出窗口:

[英]Reopened pop window on browser reload:

openerWindow.php将通过一个按钮调用openedWindow.html ,但是为什么当我关闭openedWindow.html并刷新浏览器时, openedWindow会再次出现? 这不是通过按钮触发的弹出窗口。 我不知道为什么,为什么以及如何解决这个问题:

openerWindow.php

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<form method="post" action="">
<input type="submit" name="open" value="open pop up" onclick=""/>

<?php
if(isset($_POST["open"])){ // if button clicked call other html page as pop up

?>
    <script >
    newWindow = window.open('openedWindow.html', 'formUntukUpte', 'width=400,height=350');


   </script>
<?php
}
?>

</form>
</body>
</html>

opensWindow.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

</body>
</html>

非常感谢您的帮助,

刷新时,浏览器可能会保留帖子数据。

您可以通过添加<?php print_r($_POST); ?> <?php print_r($_POST); ?>到页面,您将看到帖子数据是否仍然存在。

似乎在javascript中这样做会更容易:

<button onclick="window.open('openedWindow.html', 'formUntukUpte', 'width=400,height=350')">Open Popup</button>

如果您需要使用PHP进行操作,则需要将值存储在会话变量中,例如:

<?php
session_start();
if (isset($_POST['open'] && !isset($_SESSION['popup_shown'])) {
$_SESSION['popup_shown'] = true;
?>
<script>
//popup launch
</script>
<?php
}
?>

暂无
暂无

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

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