Heim  >  Artikel  >  Backend-Entwicklung  >  php 弹框

php 弹框

WBOY
WBOYOriginal
2016-06-20 12:35:221088Durchsuche

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


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


回复讨论(解决方案)

要改成这样的
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跳转

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn