现在的位置: 首页 > 综合 > 正文

javascript: The Browser Object Model(BOM)

2013年10月02日 ⁄ 综合 ⁄ 共 1109字 ⁄ 字号 评论关闭

window

  • window对象是浏览器或者框架自身.top总是浏览器,parent是父框架,self表示自己.
    window通常可以省略.
  • 窗口操作: moveBy(dx, dy), moveTo(x, y),
    resizeBy(dw, dh), resizeTo(w, h).
  • 导航: window.open(url, frame
    name, attribute). attribute可以是left, top, height, width, resizable,
    scrollable, toolbar, status, location(all default no). 

    • window.open
      返回新窗口引用,并且有一个opener对象表示父窗口
    • window.close.
  • 对话框:
    alert, confirm, prompt.
  • 状态栏: window.status, window.defaultStatus

  • 间间隔和暂停: timeoutId = setTimeout("alert('hello world')", 1000);
    clearTimeout(timeoutId);类似有setInterval和clearInterval.
  • 历史:
    window.history.go(+-n), history.back, history.forward. history.length


document

  • alert(window.document
    == document) == true. 他是唯一一个既属于DOM又属于BOM的对象
  • 属性:title, URL,
    referrer, lastModified
  • 集合属性: anchors, applets, embeds, forms,
    images, links.
  • 方法: write, writeln.
    必须在完全载入页面前调用write()和writeln()方法. 如果任何一个方法是在页面载入后调用的,它将抹去页面的内容,显示指定的内容.


location

  • window和
    document的属性,相互等价.
  • 属性: hash(位于#后面的东西), host, hostname, href,
    pathname, port, protocol, search(位于?后面的东西).
  • 方法: assign(),
    replace(), reload(false=从缓存中导入(default),true=从服务器端导入)


navigator和
screen对象

  • navigator对象表示了浏览器本身,可以获取一些属性,但是各个浏览器支持不同.
  • screen
    对象可以得到用户系统的信息,如availHeight, availWidth(可用屏幕宽度和高度,排除了系统任务栏), colorDepth,
    height, width.

抱歉!评论已关闭.