HTML 重定向 定时跳转刷新页面

开发过程中,很多时候需要跳转页面来进行提示,而提示需要定时跳转,实现的方法有很多.这里介绍一个相对简单的

利用HTML的 Meta 实现重定向或刷新页面;

例子1:刷新当前页面

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <meta http-equiv="refresh" content="1000"> 
        <title>隔1000秒刷新当前页面</title>
    </head>
<body>
</body>
</html>    

例子2:跳转至指定页面

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
        <meta http-equiv="refresh" content="5;url=http://www.cnblogs.com/lingfengchencn">
        <title>隔3秒刷新到http://www.cnblogs.com/lingfengchencn</title>
    </head>
<body>
</body>
</html>            

利用meta实现跳转,非常方便哈.那下面就是如何在程序代码中实现了.

$time = 3;
$url = 'http://www.cnblogs.com/lingfengchencn';
 $msg    =   "隔{$time}秒之后自动跳转到{$url}!";
$str    = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
$str   .=   $msg;
echo $str;
原文地址:https://www.cnblogs.com/lingfengchencn/p/2913799.html