php中頁面跳轉問題討論

      當上一個操做完成以後或者當某段內容輸出以後,但願頁面停留幾秒,而後跳轉到指定頁面的問題!這種問題很常見,最典型的例子就是12306網站當購票付款成功以後,會停頓幾秒,而後跳回到車票列表頁javascript


方法一:php

直接利用php中的header()方法
html

此處輸出內容後,停頓三秒,而後跳轉到百度首頁
java

<?php
date_default_timezone_set('Asia/Shanghai');
/*
 * 此到處理業務邏輯
 */
echo 'test'."<br/>";
echo date('Y-m-d H:i:s',time());

//跳轉
header("refresh:3;url=http://www.baidu.com");
?>

方法二:網站

利用HTML中的meta標籤的 http-equiv屬性ui

<html>   
<head>    
<meta http-equiv="refresh" content="3;URL=http://www.baidu.com/">
</head>   
<body>   
這裏頁面會停頓三秒
</body> 
</html>

content中的3表示停頓三秒,url表示要跳轉的地址url

方法三:code

利用JS中的setTimeout()方法實現htm

<html>
    <head>
        <script type="text/javascript">
            setTimeout('window.location="http://www.baidu.com/"',3000)
        </script>
    </head>
<body>
    頁面將停頓三面,而後跳轉
</body>
</html>
相關文章
相關標籤/搜索