PHP中實作頁面跳轉有以下幾種方式
在PHP腳本代碼中實作
header('location:main.php');
延遲跳轉(比如登陸成功后會有幾秒鐘等待時間,然后跳轉到了其他頁面)
header('Refresh:3;url=main.php');
或者
sleep(3); header('location:main.php');
在js腳本代碼中實作
1.window.location.href方法
<script> window.location.href = 'main.php'; </script>
使用js方法實作延遲跳轉
<script> setTimeout("window.location.href = 'https://www.cnblogs.com/chenyingying0/p/main.php'",3000); </script>
2.window.location.assign方法 延遲跳轉方法同上
<script> window.location.assign = 'main.php'; </script>
4.window.open方法 三個引數,第一個URL地址,第二個打開新頁面方式(比如新頁面_blank,_new,自身跳轉_self),第三個是新頁面的方式,包括樣式,位置等,
<script> window.open('main.php','_blank','width=200px'); </script>
(如果被瀏覽器攔截,改為允許即可)
使用HTML腳本代碼完成跳轉
在<head>標簽里執行代碼,直接插入這句代碼就可以
<html> <head> <meta http-equiv="refresh" content="3;url='main.php'"> </head> </html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/30819.html
標籤:PHP
上一篇:php單檔案上傳和多檔案上傳
下一篇:php實作簡單留言板功能
