网页跳转实现的多种方式

来源:互联网 发布:阿里云服务器华东2 编辑:程序博客网 时间:2024/05/16 06:27

1.PHP后台代码实现

function redirect($url) {   header('Location: ' . $url);}

2.通过HTML代码实现

<head>    <meta http-equiv="refresh" content="5;url=hello.html"> </head> 

3.通过js实现

/** * 跳转 * @param {Object} url * @param {Object} time */function hrefTo(url, time) {    if (time == 0) {        window.location.href = url;    } else {        setTimeout("hrefTo('" + url + "',0)", time);    }}