方法如下:
第一種:利用header()函數進行重定向。
(推薦教程:php視頻教程)
注意:locationhe和“:”之間不能有空格。
<?php header('content-type:text/html;charset=uft-8); //重定向頁面 header('location:index.php'); ?>
第二種:利用HTML 頭部中的 meta標簽,定義http-equiv=refresh 和content=”跳轉花費的時間(秒為單位);url=跳轉地址”
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> //跳轉頁面,跳轉時間:3秒鐘,目標地址:index.php <meta http-equiv="refresh" content="3;url=index.php"> <title>skip...</title> </head>
或
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> //跳轉頁面,跳轉時間:2秒鐘,目標地址:index.php <meta http-equiv="refresh" content="2;url=<?php echo $url; ?>"> <title>skip...</title> </head>
第三種:利用javascript進行跳轉
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; //立即跳轉至目標頁面 echo <script>window.location.href='$url';</script>; ?>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com