关于BOM知识的整理

概述:

  BOM:浏览器对象模型(Browser Object Model)

  BOM包含内容:

    window对象(核心
    location对象
    navigator对象
    screen对象
    history对象

一、window对象

  双重身份:全局(Global)对象;浏览器的实例。

  窗口关系及框架:window.frames,集合。
          top.frames:最外层的框架。

  窗口大小:window.innerWidth / window.innerHeight 。

  导航和打开窗口:window.open(),打开窗口,接收4个参数:URL、窗口目标、窗口属性(字符串)、是否取代浏览器历史记录(布尔值)。

  定时器:setTimeout() / setInterval() ;

  系统对话框:alert() / confirm() / prompt()  警告/确认/输入。

二、location对象

  window.location与document.location引入同一个对象。

  查询字符串参数:location.scarch

  哈希值:location.hash

三、navigator对象

  用户代理信息:window.navigator.useragent,可以获得用户的操作系统、浏览器版本、渲染的内核等信息。

        注意:1. 用户的信息可以轻易伪装;
                   2. 可以利用用户代理信息,来决定展示相应的页面(pc端/手持端)。
        alert( window.navigator.userAgent )    :查看用户代理信息;
        用法实例:
                if( window.navigator.userAgent.indexOf("MSIE") !== -1 ){      alert("IE浏览器" ) ;     }
 
四、screen对象 很少使用
 
五、history对象
  跳转:history.go(),参数为数值,前进后退的页数。
  前进:history.forward()。
  后退:history.back()。
  
 

    

    

原文地址:https://www.cnblogs.com/newh5/p/4891372.html