php實(shí)現(xiàn)彈出新頁(yè)面的方法:1、使用“header("Location:".PSYS_BASE_URL."user/index");”方法實(shí)現(xiàn)彈出跳轉(zhuǎn);2、通過(guò)“header("refresh:3;url='createTag' ");”。
推薦:《PHP視頻教程》
PHP實(shí)現(xiàn)彈出提示框并跳轉(zhuǎn)到新頁(yè)面
PHP實(shí)現(xiàn)彈出提示框后返回上一個(gè)頁(yè)面
<?php echo "<script>alert('退出成功!');location.href='".$_SERVER["HTTP_REFERER"]."';</script>"; ?>
alert里面是提示的消息,href是提示后跳轉(zhuǎn)的頁(yè)面。
如果alert中文亂碼,加入下面代碼
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
我們可以考慮封裝成函數(shù)來(lái)調(diào)用,下面是我自己封裝的頁(yè)面跳轉(zhuǎn)函數(shù)
/** * 頁(yè)面跳轉(zhuǎn)方法 * @param $msg 提示說(shuō)明 * @param null $path 跳轉(zhuǎn)路徑 * @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’);
其他跳轉(zhuǎn)方法
代碼如下:
echo "<script> alert('no loginid'); </script>"; echo "<meta http-equiv='Refresh' content=0; URL=$url>";
$url就是要跳轉(zhuǎn)的頁(yè)面,同時(shí),這個(gè)還能控制跳轉(zhuǎn)時(shí)間,content后面的0就是表示0秒后跳轉(zhuǎn)。
兩個(gè)直接跳轉(zhuǎn)的方式:
代碼如下:
header("Location:".PSYS_BASE_URL."user/index");
代碼如下:
// echo "<script> alert('創(chuàng)建tag成功!'); </script>"; // header("refresh:3;url='createTag' ");