BOM

来源:互联网 发布:福山雅治 知乎 编辑:程序博客网 时间:2024/06/05 05:43

 BOM(Browser Object Document)即浏览器对象模型。(我的理解就是)

  • BOM 模型的主要应用 windows对象模型 + location对象 + history对象
Window对象是整个BOM的核心对象,
在window对主要常用的三个对象分别是:history(历史对象),document(文档对象),location(地址对象);
document包括: link(超链接),form(表单),anchor(锚)等。
表单由文本框(text)、单选按钮(radio)、按钮(button)等表单元素组成。
history(历史对象)和location(地址对象),他们对应于浏览器中的地址栏和前进/后退按钮。


BOM提供了独立于内容 而与浏览器窗口进行交互的对象;
由于BOM主要用于管理窗口与窗口之间的通讯,因此其核心对象是window;
BOM由一系列相关的对象构成,并且每个对象都提供了很多方法与属性;
BOM缺乏标准,JavaScript语法的标准化组织是ECMA,DOM的标准化组织是W3C,BOM最初是Netscape浏览器标准的一部分。


BOM-JavaScript是运行在浏览器中的,所以提供了一系列对象, 和浏览器进行交互。

 包括 windows、document、location、navigator和screen等。通常统称为浏览器对象模型。

windows对象的常用方法



以上有些方法对于一些浏览器并不支持。

<html><head><title>00</title><script type="text/javascript">function testConfirm(){var answer=window.confirm("是否退出?");if(answer){window.alert("88");//window.close();}else{window.alert(":-)");}}function testPrompt(){var res=window.prompt("请输入密码","123");alert(res);}function testmoveBy(indexX,indexY){window.moveBy(indexX,indexY);}function testmoveTo(indexX,indexY){window.moveTo(indexX,indexY);}function testresizeBy(x,y){window.resizeBy(x,y);}function testresizeTo(){window.resizeTo(200,200);}function testScrollTo(){window.scrollBy(50,50);}function testScrollBy(){window.scrollTo(250,250);}function testOpen(){window.open("http://www.iotek.com.cn","iotek","left=20,top=50,width=300,height=300,location=no,toolbar=no,status=no,resizable=no");}</script></head><body><input type="button" value="confirm" onclick="testConfirm()"/><input type="button" value="prompt" onclick="testPrompt()"/><input type="button" value="moveBy" onclick="testmoveBy(50,50)"/><input type="button" value="moveTo" onclick="testmoveTo(100,100)"/><input type="button" value="resizeBy" onclick="testresizeBy(50,50)"/><input type="button" value="resizeTo" onclick="testresizeTo()"/><input type="button" value="scrollby" onclick="testScrollBy()"/><br/><input type="button" value="scrollto" onclick="testScrollTo()"/><br/><input type="button" value="open" onclick="testOpen()"/></body></html>


原创粉丝点击