posts - 37,  comments - 9,  trackbacks - 0
          BOM:Browser Object Model,瀏覽器對象模型。BOM是由一系列的對象組成的。其結構如下圖所示。


          可以看出,window對象是整個BOM的核心,因此,先討論window對象。
          (1)使用框架集的情況下
                  使用框架集合的情況下,每個框架都由他自身的window對象表示,存放在frames集合中。可以通過數字或者名字對框架進行索引。看例子:
          <html>
              
          <head></head>
              
          <frameset rows="100,*">
                  
          <frame src="frame.html" name="topFrame" />
                  
          <frameset cols="50%,50%">
                      
          <frame src="anothorFrame.html" name="leftFrame"/>
                      
          <frame src="yetAnothorFrame.html" name="rightFrame"/>
                  
          </frameset>
              
          </frameset>
          </html>
                  我們可以通過window.frames[0]或者window.frames["topFrame"]引用頂層的框架。由于window對象是整個BOM的核心,因此再寫上面的代碼時,可以忽略window對象不寫,直接寫frames[0]或者frames["topFrame"]即可。
                  在框架中使用window對象,代表的是該框架本身。因此,還引入了top對象。該對象指向的是對頂層的框架,也就是瀏覽器窗口。
                  此外,還有一個parent對象。顧名思義,parent指向該框架的父框架。看例子。
          <!--parent.html-->
          <html>
              
          <head></head>
              
          <frameset rows="100,*">
                  
          <frame src="frame.html" name="topFrame" />
                  
          <frameset cols="50%,50%">
                      
          <frame src="anothorFrame.html" name="leftFrame"/>
                      
          <frame src="anotherframeset.html" name="rightFrame"/>
                  
          </frameset>
              
          </frameset>
          </html>
                 其中,anotherframeset.html的代碼如下:
          <!--anotherframeset.html-->
          <html>
           
          <head>
            
          <title></title>
           
          </head>
           
          <body>
              
          <frameset cols="100,*">
                  
          <frame src="red.html" name="redFrame"/>
                  
          <frame src="blue.html" name="blueFrame"/>
              
          </frameset>
           
          </body>
          </html>
                  如果在red.html或者blue.html中,parent指向parent.html中的rightFrame。如果代碼寫在parent.html中的topFrame中,那么parent指向top對象,也就是瀏覽器窗口。還有一個指針self,它總是等于window。

          參考書:
          《JavaScript高級編程》Nicolas C. Zakas著, 曹力 張欣 等譯。
          posted @ 2011-10-18 12:22 wawlian 閱讀(475) | 評論 (0)編輯 收藏

          <2011年10月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 德钦县| 磐石市| 清苑县| 谢通门县| 永德县| 尤溪县| 安溪县| 浏阳市| 晋州市| 江永县| 钟山县| 盐津县| 伊吾县| 马边| 沈阳市| 日照市| 肇庆市| 丹江口市| 临高县| 蛟河市| 清苑县| 新化县| 芦溪县| 察哈| 西乌| 会同县| 博野县| 仁寿县| 新沂市| 东城区| 古田县| 左权县| 洪江市| 澄城县| 绥棱县| 宜章县| 遵义县| 井陉县| 泽州县| 杨浦区| 闸北区|