今天发现公司所有网站都没有自定义404页面,就修改了下服务器默认的404页面,最后的效果就是这样了:

JS设置倒计时5秒后跳转到来源页

附上核心代码:

<script>
    window.onload = function(){  
    var i = 4; 
    var intervalid; 
    intervalid = setInterval(fun, 1000); 
    function fun() { 
    if (i == 0) { 
    history.back();
    clearInterval(intervalid); 
    } 
    document.getElementById("mes").innerHTML = i; 
    i--; 
    }
}
</script>
<!-- HTML部分 -->
<p><span id="mes">5</span>秒后自动返回来源页</p>

 

Last modification:June 16th, 2018 at 11:17 am
If you think my article is useful to you, please feel free to appreciate