JS 实现页面跳转

<?php
require_once 'Init.php';

$target = 'view';

if (!UserLogin::isLogin()) {
    $target = 'login';
}
?>
<script>

<?php
if ($flashes) {
    echo "time=1;";
} else {
    echo "time=0;";
}
?>

        redirect(<?php echo '"' . Utils::createLink($target) . '"'; ?>, time);
    
        function redirect(location, time){
            var i = time ; 
            if(i==0) 
                document.location.href = location;
            i--; 
            setTimeout("redirect('"+location+"',"+i+")",1000); 
        } 
</script>

说明:

1、document.location.href是JS用来实现页面跳转的

2、setTimeout() 方法用于在指定的毫秒数后调用函数或计算表达式。

 

推荐一个自己业余时间开发的网盘搜索引擎,360盘搜www.360panso.com

posted on 2012-12-13 14:04  上品物语  阅读(1448)  评论(0编辑  收藏  举报