bom对象

来源:互联网 发布:瘦脸针副作用 知乎 编辑:程序博客网 时间:2024/06/14 01:28
<!DOCTYPE html><html lang="zh-cn"><head><meta charset="UTF-8"><title>open 方法</title></head><body><input type="button" value="按钮"><input type="button" value="关闭"></body></html><script>window.onload = function(){var oBtn = document.getElementsByTagName('input');var opener = null;// open方法// open(url, 打开方式) 如果URL为空则打开一个空白页// 打开方式为空,则新窗口打开// 返回值,返回新打开窗口的对象oBtn[0].onclick = function(){// alert(this.value);// window.open('http://baidu.com','_self');opener = window.open();// alert(opener);opener.document.body.style.background = 'red';}// close// 存在兼容问题// ff:默认无法关闭// chrome:默认关闭// ie:询问用户// 通过返回值关闭,则没有兼容问题oBtn[1].onclick = function(){// window.close();alert(window.navigator.userAgent);}// window.navigator.userAgentif(window.navigator.userAgent.indexOf('MISE') != -1){alert('ie');}else{alert('不是ie');}// window.location :浏览器地址信息// window.location.url #后面的东西// window.locaton.href// window.locaton.search ? 后面的东西alert(window.location);
/** * 可视区尺寸  *  document.documentElement.clientWidth *  document.documentElement.clientHeight * 滚动距离 * document.documentElement.scrollTop/scrollLeft * document.body.scrollTop/scrollLeft * 存在兼容问题 * var scrollTop = document.documentElement.scrollTop || document.body.scrollTop * 内容高 * divObjevt.scrollHeight *  文档高(存在兼容问题) *  offsetHeight ie7下表现为可视区高 *  onscroll *  onresize */document.onclick = function(){// 滚动条滚动距离 // alert(document.body.scrollTop);// 内容高var oDiv1 = document.getElementById('div1');alert(oDiv1.scrollHeight);// 文档高alert(document.documentElement.offsetHeight);alert(document.body.offsetHeight)}window.onscroll = function(){//onscroll,onresize  触发按时间间隔计算}}

}</script>

0 0