【JavaScript】基础知识整理(四)
2016-03-30 21:44
651 查看
浏览器对象模型(BOM)
BOM使JavaScript有能力与浏览器对话window对象
所有浏览器都支持window对象。它表示浏览器窗口。所有JavaScript全局对象、函数以及变量均自动成为window对象的成员。
全局变量是window对象的属性。
全局函数是window对象的方法。
甚至HTML DOM的document也是window对象的属性之一;
window.document.getElementById( “header” );
window尺寸
有三种方法能够确定浏览器窗口的尺寸(浏览器的视口,不包括工具栏和滚动条)。对于Internet Explorer、Chrome、Firefox、Opera 以及 Safari:
window.innerHeight - 浏览器窗口的内部高度
window.innerWidth - 浏览器窗口的内部宽度
对于 Internet Explorer 8、7、6、5:
document.documentElement.clientHeight
document.documentElement.clientWidth
或者
document.body.clientHeight
document.body.clientWidth
实用的 JavaScript 方案(涵盖所有浏览器):
var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h=window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
window其他方法
window.open()window.close()
window.moveTo()
window.resizeTo()
Screen
window.screen 对象在编写时可以不使用 window 这个前缀。Location
window.location 可以不使用window这个前缀location.hostname 返回 web主机的域名
location.pathname 返回当前页面的路径和文件名
location.port 返回web主机的端口
location.protocol 返回使用的web协议(http:// 或 https://)
location.href属性返回当前页面的url
History
window.history 可省略 window 这个前缀history.back()
history.forward()
Navigator
可省略window前缀PopuAlert
Timing
cookie
相关文章推荐
- javaScript——作用域和闭包概念
- js获取Url中参数值
- JavaScript 流程控制语句
- JS高级程序设置笔记(二)
- js中的作用域链
- 【JavaScript】基础知识整理(二)
- 图说js中的this——深入理解javascript中this指针
- DOM操作,javascript动态生成表格
- js初学笔记(三)
- 【JavaScript】基础知识整理(三)
- 实用代码片段--Javascript
- js 返回前一页并刷新页面方法
- JSF学习四 标签
- javascript之原型和原型链
- 27、extjs操作用友华表Cell之合并单元格
- HTML与JSP
- 1-2-JS基础-属性操作实例
- 【JSP】简单登陆界面
- JavaScript关于对象的总结
- 解析加密后的js