js小案例:使用location.href自动跳转页面
生活随笔
收集整理的這篇文章主要介紹了
js小案例:使用location.href自动跳转页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>自動跳轉首頁</title>
<style>p{text-align : center;}span{color:red;}
</style>
</head>
<body><p><span id="time">5</span>秒之后,自動跳轉首頁...</p><script>//獲取倒計時秒數var time = document.getElementById("time");var second = 5;function showTime(){second -- ;if(second <= 0){//時間到了,跳轉首頁location.href = "https://www.baidu.com";}time.innerHTML = second;}setInterval(showTime,1000);
</script>
</body>
</html>
總結
以上是生活随笔為你收集整理的js小案例:使用location.href自动跳转页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【收藏】linux下用命令方式创建及管理
- 下一篇: deepin 15.11镜像下载地址