0

在我的代码中,我可以让一个窗口出现或另一个,但不能同时启动两个窗口。如果两个复选标记都被选中,它将默认为仅第一个。如果第二个只是检查,它将转到第二个 if/popup url 位置。如何使用 2 个不同的 url 启动两个弹出窗口?

<form action="" method="POST" target="popup">
        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']){
                echo "<script type=\"text/javascript\"> window.open('../index.php?p=members','popup','width=700,height=400,left=200,top=200,scrollbars=1') ;</script>";
                //header("location: ../index.php?p=members");
        }
        if($_POST['facebook']){
                echo "<script type=\"text/javascript\"> window.open('../index.php?p=paybill','popup','width=700,height=400,left=200,top=200,scrollbars=1') ;</script>";
                //header("location: ../index.php?p=paybill");
        }else{
                echo "Something bad happened";
        }
}
?>
4

1 回答 1

0

如果您给您的窗口起相同的名称(在您的情况下为“弹出窗口”):

window.open(url1, 'popup', options);
window.open(url2, 'popup', options);

浏览器将为第二个弹出窗口重用第一个窗口。

给你的窗口起不同的名字,例如“popup1”和“popup2”:

window.open(url1, 'popup1', options);
window.open(url2, 'popup2', options);

这将导致打开 2 个不同的弹出窗口。

于 2013-11-13T22:28:25.677 回答