window对象
window对象是一个浏览器对象,代表浏览器窗口。
我们定义的变量、函数会自动放在window对象里面。
document也是window里面的。window.document
window中的变量或者对象一般可以直接写,不加 window.前缀
为什么要把document放在window里面
window代表整个浏览器窗口,网页是位于浏览器窗口里面的,document主要是跟网页有关,跟元素相关的操作都是通过document完成的,所以可以认为document是整个网页,网页位于窗口里面。
所以document也就放在了window里面
window对象的函数(弹出框)
alert
confirm 确认框
prompt 输入框
setInterval clearInterval
setTimeout clearTimeout
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>window对象</title>
<script type="text/javascript">
//window浏览器窗口
// var name = "siki";
// console.log(window.name);
// window.document.getElementById();
// window.alert();
// window.setInterval();
// window.setTimeout();
// var res = window.confirm("你确定要杀我吗?");
// console.log(res);
var res = window.prompt("请输入你的性别:");
console.log(res);//输入结果,确定才会显示输入的内容,点击取消,显示null。
</script>
</head>
<body>
</body>
</html>