标签:fun set add javascrip zh-cn event java document oca
<!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>
标签:fun set add javascrip zh-cn event java document oca
原文地址:https://www.cnblogs.com/nigori/p/10770569.html