日期:2014-05-17  浏览次数:20649 次

打开jsp/html,3秒后自动跳转

打开一个页面,过几秒跳转,一般会应用在某些操作成功或者失败之后,给出提示,然后跳回到别的页面。比如你注册成功或者失败后,添加成功后者失败后。效果稍微好点儿的,会用隐藏域或者ajax在页面上直接提示并刷新,不会通过这种的页面进行跳转,效果和操作体验都要比这种几秒自动跳转要好,但是这里,我还是把这种的记录一下。

 

第一种:<script> window.setInterval("location='index.jsp'",3000); </script>  使用interval函数跳转,这里的3000是毫秒单位,也就是3秒。

 

第二种:<meta http-equiv="refresh" content="3;url=http://localhost:8080/test/index.jsp" />,这里的content=3,便是3秒的跳转。

 

第三种:<script type="text/javascript">

delayURL("index.action",3000);

function delayURL(url, time) {

     setTimeout("location.href='" + url + "'", time);

}

   </script>

 

第四种:<script type="text/javascript">

function countDown(time,url){

    $("#second").text(time);//<span>中显示的内容值

     if(url==''){