<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div></div>
<script>
var div = document.querySelector('div');
var time = 5;
timer();
setInterval(timer, 1000)
function timer() {
if (time == 0) {
location.href = 'http://www.baidu.com'
} else {
div.innerHTML = '将在' + time + '秒后跳转到百度';
time--;
}
}
</script>
</body>
</html>
js-5秒之后跳转页面
最新推荐文章于 2023-12-04 16:55:42 发布