php实现页面重定向及限时跳转的几种方法
本文发布于 12 年前, 内容可能已经过时或失效!
php实现页面跳转及限时跳转的几种方法:
## 1.使用php里head函数进行跳转
```php
header("refresh:3;url=http://yanue.net");//限时跳转
header('location:http://yanue.net');//立即跳转
```
**注意**:head跳转前不要有任何输出,不然可能不能跳转.
## 2. HTML meta refresh 刷新与跳转(重定向)页面
#### **refresh** 属性值 -- 刷新与跳转(重定向)页面
- refresh用于刷新与跳转(重定向)页面
- refresh出现在http-equiv属性中,使用content属性表示刷新或跳转的开始时间与跳转的网址
```html
<meta http-equiv="refresh" content="3; url=http://yanue.net">
```
## 3.js实现页面跳转
```javascript
<script type='text/javascript'>
// 立即跳转
window.location.href = 'http://yanue.net';
// 限时跳转
setTimeout(function(){
// 3秒后跳转
window.location.href = 'http://yanue.net';
},3000);
</script>
```