JS内置对象Window
在JavaScript中
- 所有的全局变量都是window的属性
- 所有的全局函数都是window的方法
var age = 17;
function testAge() {
console.log(window.age);//等同于console.log(age);
}
window.testAge();//等同于testAge();
window.console.log(age);//等同于console.log
console.log(window);
window还可以动态的跳转页面
window.location.href = 'https://www.apple.com';
也可以用于和OC或Swift进行交互
window.location.href = 'ZF://openCamera?user=zhangfan'