簡體   English   中英

如何使用php而不是javascript重定向到彈出窗口?

[英]How do you redirect to a popup using php and not javascript?

我在JavaScript中找到了很多方法,但是我需要在php腳本中間調用smack。

<form action="" method="POST" target='popup' onsubmit="window.open('','popup','width=700,height=400,left=200,top=200,scrollbars=1')">
        Send a message  : <input type="text" name="twitmessage"><br>
        <input type="checkbox" name="twitter" value="My Posting Text">Would you like to send to Twitter?<br>
        <input type="checkbox" name="facebook" value="Stuff to Post to facebook">Would you like to post to Facebook?<br>
        <input type="submit" name="submit_cycle" value="Submit">
</form>
<?php
session_start();
// store session data
$_SESSION['twitmessage'] = $_POST['twitmessage'];

if(isset($_POST['submit_cycle'])) {
        if($_POST['twitter']){
                header("location: ../index.php?p=members");
        }
        if($_POST['facebook']){
                header("location: ../index.php?p=paybill");
        }else{
                echo "Something bad happened";
        }
}
?>

你不能

打開窗口是客戶端操作,無法使用PHP執行。 那是原則上的。

您可以生成JS,這將在客戶端打開一個新窗口。

<script>
    window.open('<?php echo htmlentities($url); ?>')
</script>

另一種方法。 也許我沒聽清您的意圖。

要在其他窗口中打開Twitter對話框,您只需將target=_blank添加到表單中。

其余應與上面相同。

要創建一個大小合適的窗口,請創建一個新的命名窗口。 然后縮放它,並將表單的目標設置為窗口的名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM