window对象
作者:
L了个Z | 来源:发表于
2016-10-29 16:38 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>内置对象-window</title>
<script>
// window
// 第一大用途
// 1.所有的全局变量都是window的属性
// 2.所有的全局函数都是window的方法
var age = 20;
// console.log(window.age);
function Test() {
var name = 'Jack';
console.log('我是全局函数' + window.age);
}
// Test();
// window.Test();
function Test2() {
console.log(this);
}
Test2(); // window
new Test2(); // Test2{}
window.alert(0);
// console
// 第二大用途: 动态的跳转
// window.location.href = 'http://www.baidu.com';
// window.location.href = 'xmg://user=zhangsan&pwd=5678i64557'
</script>
<body>
</body>
</html>
本文标题:window对象
本文链接:https://www.haomeiwen.com/subject/chjyuttx.html
网友评论