A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© nigori 中级黑马   /  2019-4-26 16:45  /  1133 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

[AppleScript] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>点击跳转</button>
<div></div>
<script>
    var btn = document.querySelector('button');
    btn.addEventListener('click', function () {   // 注册按钮点击事件
        location.href = "http://www.baidu.com";  //  要跳转到的地址
    });
    var div = document.querySelector('div');
    var time = 5;   // 这里设置自动跳转的时间

    function f() {
        if (time > 0) {
            div.innerHTML = time + "s后跳转页面";
            time--;
        } else {
            location.href = 'http://www.baidu.com';  // 要跳转到的地址
        }
    }

    setInterval(f, 1000);  // 计时器

</script>
</body>
</html>

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马