Home > Backend Development > PHP Problem > How to pop up prompt box in php

How to pop up prompt box in php

silencement
Release: 2023-02-25 06:44:01
Original
6774 people have browsed it

How to pop up prompt box in php

The method of popping up a dialog box in php is as follows. Generally, a dialog box prompt needs to pop up after submitting the information, and then the dialog box can be automatically closed. There are following centralized methods for popping up a dialog box. In fact, they are all It uses the alert() method in javascript. Closing the current page after the prompt ends can also be achieved using javascript's Window.self.close().

The exact statement is:

echo   " <script> window.self.close(); </script> ";
Copy after login

1. PHP pops up the dialog box

//弹出对话框
alert(\"你好\");";
?>

//关闭当前页

echo   " <script> window.self.close(); </script> ";
或者
alert(\"你好\");";
?>
Copy after login

2. If you need PHP to pop up the dialog box and return to the original page, you can write like this

<?php
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"你好\");\r\n";
echo " history.back();\r\n";
echo "</script>";
exit;
?>
或者
<?php
print "<script language=\"JavaScript\">\r\n";
print " alert(\"你好\");\r\n";
print " history.back();\r\n";
print "</script>";
exit;
?>
Copy after login

3. If you need PHP to pop up a dialog box and replace the original page with a new page (replace the current history record), the original page can be written like this

<?php
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"你好\");\r\n";
echo " location.replace(\"http://www.asm32.net/\");\r\n"; // 自己修改网址
echo "</script>";
exit;
?>
或者
<?php
print "<script language=\"JavaScript\">\r\n";
print " alert(\"你好\");\r\n";
print " location.replace(\"http://www.asm32.net/\");\r\n"; // 自己修改网址
print "</script>";
exit;
?>
Copy after login

The above is the detailed content of How to pop up prompt box in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template