php 弹框

WBOY
Release: 2016-06-20 12:35:22
Original
1150 people have browsed it

if($mail -> Send()){    echo "<script>alert('Success')</script>";    header("Location: homeConnect.php");}else{    echo "<script>alert('Failed')</script>";    header("Location: homeConnect.php");}
Copy after login


不管成功还是失败,都没有弹框直接跳转了
想要的效果:显示弹框信息,用户点确定后跳转


回复讨论(解决方案)

要改成这样的
echo "<script>alert('Failed')</script>";
echo "<script>location: homeConnect.php</script>";

header("Location: homeConnect.php");
在 http 头中产生跳转指令,所以跳转发生于脚本执行之前

要改成这样的
echo "<script>alert('Failed')</script>";
echo "<script>location: homeConnect.php</script>";

header("Location: homeConnect.php");
在 http 头中产生跳转指令,所以跳转发生于脚本执行之前



不会跳转

echo "<script>location.href= 'homeConnect.php';</script>";

用script跳转

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