php实现弹出新页面的方法:1、使用“header("Location:".PSYS_BASE_URL."user/index");”方法实现弹出跳转;2、通过“header("refresh:3;url='createTag' ");”。

推荐:《PHP视频教程》
PHP实现弹出提示框并跳转到新页面
PHP实现弹出提示框后返回上一个页面
<?php
echo "<script>alert('退出成功!');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
?>alert里面是提示的消息,href是提示后跳转的页面。
立即学习“PHP免费学习笔记(深入)”;
如果alert中文乱码,加入下面代码
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
我们可以考虑封装成函数来调用,下面是我自己封装的页面跳转函数
/**
* 页面跳转方法
* @param $msg 提示说明
* @param null $path 跳转路径
* @param null $parent 为ture则返回父窗口
*/
function messageInfo($msg,$path=NULL,$parent=NULL){
if($parent === true){
$str="<script>alert('".$msg."');parent.location.href='".$path."‘</script>";
}else if(empty($path)){
$str="<script>alert('".$msg."');history.back()</script>";
}else{
$str="<script>alert('".$msg."');location.href='".$path."'</script>";
}
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';//支持中文
echo $str;
}使用方法:messageInfo(‘操作成功!’,’http://www.demourl.com/product_list.php’);
其他跳转方法
代码如下:
echo "<script> alert('no loginid'); </script>";
echo "<meta http-equiv='Refresh' content=0; URL=$url>";$url就是要跳转的页面,同时,这个还能控制跳转时间,content后面的0就是表示0秒后跳转。
两个直接跳转的方式:
代码如下:
header("Location:".PSYS_BASE_URL."user/index");代码如下:
// echo "<script> alert('创建tag成功!'); </script>";
// header("refresh:3;url='createTag' ");以上就是php如何实现弹出新页面的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号