js倒计时跳转链接

时间:2022-01-03 22:04:28
(function(){

            var    loadUrl = 'http://www.cnblogs.com/naokr/',//跳转链接
                loadTime = 3000,//跳转时间
                reTime = 1000;
                reIn = setInterval(showTxt,reTime);
            function showTxt(){
                if(loadTime > reTime){
                    loadTime = loadTime - reTime;
                    document.getElementById('tsnid').innerHTML = parseInt(loadTime/reTime);
                }else{
                    window.location = loadUrl; 
                }
            }

        }());