簡體   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