BOM 浏览器对象模型
window 窗口
- window.outerWidth/outerHeight - 完整窗口大小
- window.innerWidth/innerHeight - 文档显示区大小
- window.open() - 打开新窗口
- window.close() - 关闭当前窗口
- window.moveTo() -移动当前窗口
- window.resizeTo() -重新调整当前窗口
screen 屏幕信息
- screen.width - 以像素计的访问者屏幕宽度
- screen.height
- screen.availWidth - 减去诸如窗口工具条之类的界面特征的屏幕宽度
- screen.availHeight
- screen.colorDepth - 色深 24,32
- screen.pixelDepth - 像素深 24
location 位置
- window.location.href 返回当前页面的 href (URL)
- window.location.hostname 返回 web 主机的域名
- window.location.pathname 返回当前页面的路径或文件名
- window.location.protocol 返回使用的 web 协议(http: 或 https:)
- window.location.assign 加载新文档 就是跳转
<!DOCTYPE html>
<html>
<body>
<h1>window.location 对象</h1>
<input type="button" value="加载新的文档" onclick="newDoc()">
<script>
function newDoc() {
window.location.assign("http://www.w3school.com.cn")
}
</script>
</body>
</html>
history 历史记录
- history.back() - 等同于在浏览器点击后退按钮
- history.forward() - 等同于在浏览器中点击前进按钮
<html>
<head>
<script>
function goBack() {
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
- navigator:浏览器配置信息
navigator.appName
navigator.appCodeName
navigator.platform 等等 多半都是被固化的值
- document: 正在加载的网页内容
event 事件
- onclick 点击
<button onclick="displayDate()">试一试</button>
- onload 用于检测访问者的浏览器加载页面
<body onload="checkCookies()">
- onunload 用于删除cookie
- onchange
<input type="text" id="fname" onchange="upperCase()">
- onmouseover onmouseout
- onfcus 当输入字段获得焦点时改变其背景色
554




被折叠的 条评论
为什么被折叠?



