自动跳转其他网页

此代码会在5秒后自动跳转其他界面,点击按钮后直接跳转

<!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>
<button>点击</button>
<div></div>
<script>
var btn = document.querySelector('button');
var div = document.querySelector('div');
btn.addEventListener('click', function() {
// console.log(location.href);
location.href = 'http://www.itcast.cn';
})
var timer = 5;
setInterval(function() {
if (timer == 0) {
location.href = ' 输入需要跳转的网址链接,请勿删除引号 ';
} else {
div.innerHTML = '您将在' + timer + '秒钟之后跳转';
timer--;
}
}, 1000);
</script>
</body>
</html>
<!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>
    <button>点击</button>
    <div></div>
    <script>
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        btn.addEventListener('click', function() {
            // console.log(location.href);
            location.href = 'http://www.itcast.cn';
        })
        var timer = 5;
        setInterval(function() {
            if (timer == 0) {
                location.href = ' 输入需要跳转的网址链接,请勿删除引号 ';
            } else {
                div.innerHTML = '您将在' + timer + '秒钟之后跳转';
                timer--;
            }

        }, 1000);
    </script>
</body>

</html>
<!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> <button>点击</button> <div></div> <script> var btn = document.querySelector('button'); var div = document.querySelector('div'); btn.addEventListener('click', function() { // console.log(location.href); location.href = 'http://www.itcast.cn'; }) var timer = 5; setInterval(function() { if (timer == 0) { location.href = ' 输入需要跳转的网址链接,请勿删除引号 '; } else { div.innerHTML = '您将在' + timer + '秒钟之后跳转'; timer--; } }, 1000); </script> </body> </html>

 

©造梦空间论坛 BY 长沙造梦空间网络科技有限公司
自动跳转其他网页-造梦空间论坛
自动跳转其他网页
此内容为付费阅读,请付费后查看
3积分
联系客服:tencent110tx
付费阅读
© 版权声明
THE END
喜欢就支持一下吧
点赞3 分享
Put your heart, mind, and soul into even your smallest acts. This is the secret of success.
即便是再微小不过的事情,你也要用心去做。这就是成功的秘密
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容