document.frames()與document.frames[]

document.frames()與document.frames[]

document.frames('reportFrame').document
不是很瞭解,有兩個document,其中document.frames('reportFrame')指的是當前文檔中一個name屬性爲'reportFrame'的frame的window對象(不是DOM對象),而後接一個".document"就取得了DOM對象,這個DOM對象就是你要查找frame中ID爲reportFrameForm的DOM對象的context

$("#reportFrameForm",document.frames('reportFrame').document)
先解釋document.frames('reportFrame').document
這句是原生態的javascript意思是.獲取當前文檔(document)裏框架集(frames)裏id/name爲reportFrame文檔(最後的那個document)

jQuery語法:$(選擇器,[待查文檔])
若是沒有指定[待查文檔]就是$(選擇器)這樣,指從當前文檔查詢.若是指定了[待查文檔]就從指定的待查文檔裏查詢選擇器.

$("#reportFrameForm"
的意思就是"找到id爲reportFrameForm的DOM元素

$("#reportFrameForm",document.frames('reportFrame').document)
整句的意思就是:
從當前頁面的名字爲reportFrame的框架頁面裏找到id爲reportFrameForm的元素.
----------------
大體能夠猜出這句是操做嵌入頁裏的一個叫reportFrameForm的表單 javascript


document.frames()與document.frames[]的區別 html


<html>
<body>
<iframe id="ifr_1"
name="ifr_1">
</iframe>
</body>
</html>
其中:
document.frames(「ifr_1」)能夠獲得一個 window對象
document.frames[「ifr_1」] 能夠獲得一個Html Element DOM對象

 

 

 

-______________________________________________ java

 

 <script type="text/javascript">   //使用原生態javascript操做DOM   function getFrameDom(){    var aa = window.parent.frames["topFrame"].document.getElementsByName("n");    for ( var i = 0; i < aa.length; i++) {     alert(aa[i].style.display = "");    }    var a = document.frames("topFrame");    alert("a----" + a);    var b = document.frames["topFrame"];    alert("b----" + b);   }  </script>   </head>     <body bgcolor="#33CCFF">      我是列表頁面<br>      獲取頂層fram的DOM對象<input onclick="getFrameDom();" type="button" value="跳轉新頁面 add.jsp"><br>      獲取頂層fram的window對象<input onclick="" type="button" value="跳轉新頁面 add.jsp"><br>    </body>
相關文章
相關標籤/搜索