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