404页面上常用到倒计时返回指定页面,下面是jquery和php结合倒计时返回指定页面,代码如下:
<?php
$url=”http://zhoumo123.cn/“;
$num=”10″;
?>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script> <script type="text/javascript"> var gcisNum = <?php echo $num; ?>; $(function(){ gcisSetNum(); }); function skipNum() { $("#skip").html(gcisNum-1); gcisNum--; if(gcisNum) { gcisSetNum(); } else { window.location='<?php echo $url; ?>'; } } function gcisSetNum() { setTimeout("skipNum()", 1000); } </script> <div>系统在 <span id="skip"><?php echo $num; ?></span> 秒后自动跳转到首页。</div>