window对象

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Window对象</title>

</head>
<body>
<input type="button" id="openBtn" value="打开按钮">
<input type="button" id="closeBtn" value="关闭按钮">

<script>
//与窗口弹出相关
alert("this is test");
var flag = confirm("你确定要退出吗?");
if(flag){
document.write("bye-bye"+"<br>");
}else{
document.write("noties"+"<br>");
}
var result = prompt("请输入用户名");
document.write(result+"<br>")

//与窗口打开关闭有关

var openbtn= document.getElementById("openBtn");
var newWindow;
openbtn.onclick = function(){
newWindow = open("https://www.baidu.com");
}

var closebtn = document.getElementById("closeBtn");
closebtn.onclick=function () {
newWindow.close();
}

//与定时器有关
function fun() {
document.write("bomb.....");
}
var id = setTimeout(fun,3000);
clearTimeout(id);

var interval = setInterval(fun,3000);
clearInterval(interval);

</script>
</body>
</html>
原文地址:https://www.cnblogs.com/newcityboy/p/11403180.html