属性
- Window.innerHeight 浏览器窗口的视口(viewport)高度(以像素为单位);如果有水平滚动条,也包括滚动条高度 window.innerHeight 属性为只读,且没有默认值。想获取窗口的外层高度(outer height),即整个浏览器窗口的高度,请查看 window.outerHeight 语法:
var intViewportHeight = window.innerHeight;
- Window.innerWidth 只读的 Window 属性 innerWidth 返回以像素为单位的窗口的内部宽度。如果垂直滚动条存在,则这个属性将包括它的宽度。并且是一个整数型的值
- Window.history 是一个只读属性,用来获取History对象的引用,History对象提供了操作浏览器的会话历史的接口
history.back() 回到历史记录的上一个页面
history.forward() 去到历史记录中的下一个页面
history.go(n) 去到历史记录中指定的页面
history.go(2) 去到历史记录的下两个页面
history.go(-1) 相当于history.back()
location对象
location 对象中就存储而来浏览器的地址信息
console.log(location);//Location {ancestorOrigins: DOMStringList, href: "file:///E:/%E5%8D%83%E5%B3%B0%20%E5%9F%B9%E8%AE%AD…E7%9A%84%E5%9C%B0%E5%9D%80%E4%BF%A1%E6%81%AF.html", origin: "file://", protocol: "file:", host: "", …}
location.href
location对象中的href属性就是浏览器访问的完整地址,会将地址张的中文转码为url中的编码格式; 也可以通过location.href来实现浏览器的跳转,会直接跳转到指定的url地址
console.log(location.href);//打印出完整的地址;
btn.onclick = function(){
location.href = 'http://1000phone.com';
}//通过点击事件可以实现跳转到指定的url地址;
location.reload()
重新加载页面,这个方法不要写在全局中,会一直重现加载
navigator对象
记录的是浏览器的各种信息(不一定有效)
console.log(navigator.userAgent)//获取浏览器的版本信息
浏览器的弹出层
- alert() 提示弹框 没有返回值
- confirm() 询问弹窗
点击确定的时候返回true
点击取消的时候返回false - prompt() 提示输入弹窗