php 如何通过echo使用php创建弹出窗口?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7437713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:40:12  来源:igfitidea点击:

How to create a pop up window using php via echo?

phppopup

提问by John

Is it possible to make a pop up window in my existing script?

是否可以在我现有的脚本中创建一个弹出窗口?

session_start();

$_SESSION['success'] = ($result) ? TRUE : FALSE;

header('location: inv_fc.php');


session_start();
if ($_SESSION['success'] == TRUE) {
// CREATE POP UP WINDOW SUCCESS
} else {
// CREATE POP UP WINDOW FAILURE
}

回答by Griwes

You could open a pop-up using javascript or target a's attribute, but it's impossible from PHP, which is executed at server side.

您可以使用 javascript 或目标 a 的属性打开一个弹出窗口,但在服务器端执行的 PHP 中这是不可能的。

Edit: ok, as I saw the <script>things: it's not PHP, it's Javascript, from PHP it's not possible.

编辑:好的,正如我所看到的<script>:它不是 PHP,它是 Javascript,从 PHP 是不可能的。

回答by someone

You can do it with Javascript. For nicer results, use jQuery UI.

你可以用 Javascript 来做到这一点。要获得更好的结果,请使用jQuery UI

if ($_SESSION['success'] == TRUE) {
    echo "<script>alert('Success!');</script>";
} else {
    echo "<script>alert('Failure.');</script>";
}

回答by Naftali aka Neal

<?php if ($_SESSION['success'] == TRUE)?>
  <script>window.open(...);alert('Your Awesome!');</script>
<?php else ?>
  <script>window.open(...);alert('You Fail!!');</script>
<?php endif; ?>