JS n秒后自动跳转实例

<p><a href="<?php echo base_url();?>usercenter/index" id="message"></a> </p> 

<script type="text/javascript"> var time = 0; var forward_url ="<?php echo base_url();?>usercenter/index";//某页网址 function forward_to(){ time ++; if(time == 5){ document.location.href = forward_url; } document.getElementById("message").innerHTML = (5-time) + "秒后自动跳转到某页"; } window.setInterval("forward_to()",1000); </script>

 

posted @ 2013-12-05 11:53  静心聆听  阅读(345)  评论(0编辑  收藏  举报