您当前的位置: 首页 > 

梁云亮

暂无认证

  • 3浏览

    0关注

    1211博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

网页n秒后自动跳转

梁云亮 发布时间:2019-10-22 17:55:32 ,浏览量:3

网页n秒后自动跳转
  • 方式一:
    
    
        
            
             
            中转页面
        
        
            3秒之后自动跳转到res.html
        
    
    
  • 方式二:
    
    
        
            
            中转页面
        
        
        
            onload=function(){  //在进入网页的时候加载该方法
                setTimeout(go, 3000);   //单位ms
            };
            function go(){
                location.href="res.html";
            }
        
        //3秒之后自动执行go方法,直接跳转到index.jsp页面
        
    
    
  • 方式三:
    
    
        
            
            中转页面
        
        
        
            onload=function(){
                setInterval(go, 1000);
            };
            var x=3; //利用了全局变量来执行
            function go(){
                x--;
                if(x>0){
                    document.getElementById("sp").innerHTML=x; //每次设置的x的值都不一样了。
                }else{
                    location.href='res.html';
                }
            }
        
        
        //3秒之后自动执行go方法,直接跳转到index.jsp页面
        
    
    
  • 方式四:使用JQuery
    
    
        
            
            中转页面
            
        
        
        
            var timeID = 0;
            var timeLeft = 3;
            function count() {
                timeLeft--;
                $('#sp').text(timeLeft);
                if (timeLeft 3
        //3秒之后自动执行go方法,直接跳转到index.jsp页面
        
    
    
关注
打赏
1665409997
查看更多评论
立即登录/注册

微信扫码登录

0.0559s