js中top/parent/frame概述及案例應(yīng)用
更新時間:2013年02月06日 11:43:35 作者:
top:永遠(yuǎn)指分割窗口最高層次的瀏覽器窗口;parent:包含當(dāng)前分割窗口的父窗口,本文將圍繞js中top、parent、frame進(jìn)行講述及他們的應(yīng)用案例
引用方法top:
該變量永遠(yuǎn)指分割窗口最高層次的瀏覽器窗口。如果計劃從分割窗口的最高層次開始執(zhí)行命令,就可以用top變量。
parent:
該變量指的是包含當(dāng)前分割窗口的父窗口。如果在一個窗口內(nèi)有分割窗口,而在其中一個分割窗口中又包含著分割窗口,則第2層的分割窗口可以用parent變量引用包含它的父分割窗口。
附:Window對象、Parent對象、Frame對象、Document對象和Form對象的階層關(guān)系
Windwo對象→Parent對象→Frame對象→Document對象→Form對象,如下:
parent.frame1.document.forms[0].elements[0].value;
在JS中:window.location(window.location.href)和window.top.location(window.top.location.href)是一樣的意思 可以通過top來調(diào)用任何一個frame,因為top指的是最外層的frameset,可以調(diào)用它里面的任何一個子元素frame。如:top.outterFrame1.location和top.innerFrame2.location等。
parent指的是當(dāng)前窗口(frame)的父窗口(frameset)可以調(diào)用它里面的任何一個子元素frame。如:parent.innerFrame1.location和parent.innerFrame2.location等。
<html>
<head>
<title>top frame parent示例</title>
<script language="javaScript" type="text/javaScript">
window.location.;
</script>
</head>
<frameset id="outFrameset" rows="150,*,150" cols="*" border="5">
<frame name="frameName1" id="frameId1" src="a.html">
<frameset id="inFrameset" cols="150,*" rows="*">
<frame name="innerFrameName1" id="innerFrameId1" src="a.html">
<frame name="innerFrameName2" id="innerFrameId2" src="a.html">
</frameset>
<frame name="frameName2" id="frameId2" src="a.html">
</frameset>
</html>
該變量永遠(yuǎn)指分割窗口最高層次的瀏覽器窗口。如果計劃從分割窗口的最高層次開始執(zhí)行命令,就可以用top變量。
parent:
該變量指的是包含當(dāng)前分割窗口的父窗口。如果在一個窗口內(nèi)有分割窗口,而在其中一個分割窗口中又包含著分割窗口,則第2層的分割窗口可以用parent變量引用包含它的父分割窗口。
附:Window對象、Parent對象、Frame對象、Document對象和Form對象的階層關(guān)系
Windwo對象→Parent對象→Frame對象→Document對象→Form對象,如下:
parent.frame1.document.forms[0].elements[0].value;
在JS中:window.location(window.location.href)和window.top.location(window.top.location.href)是一樣的意思 可以通過top來調(diào)用任何一個frame,因為top指的是最外層的frameset,可以調(diào)用它里面的任何一個子元素frame。如:top.outterFrame1.location和top.innerFrame2.location等。
parent指的是當(dāng)前窗口(frame)的父窗口(frameset)可以調(diào)用它里面的任何一個子元素frame。如:parent.innerFrame1.location和parent.innerFrame2.location等。
復(fù)制代碼 代碼如下:
<html>
<head>
<title>top frame parent示例</title>
<script language="javaScript" type="text/javaScript">
window.location.;
</script>
</head>
<frameset id="outFrameset" rows="150,*,150" cols="*" border="5">
<frame name="frameName1" id="frameId1" src="a.html">
<frameset id="inFrameset" cols="150,*" rows="*">
<frame name="innerFrameName1" id="innerFrameId1" src="a.html">
<frame name="innerFrameName2" id="innerFrameId2" src="a.html">
</frameset>
<frame name="frameName2" id="frameId2" src="a.html">
</frameset>
</html>
您可能感興趣的文章:
- JS獲取scrollHeight問題想到的標(biāo)準(zhǔn)問題
- js中top、clientTop、scrollTop、offsetTop的區(qū)別 文字詳細(xì)說明版
- js中scrollHeight,scrollWidth,scrollLeft,scrolltop等差別介紹
- js獲取height和width的方法說明
- 利用JS解決ie6不支持max-width,max-height問題的方法
- js中的preventDefault與stopPropagation詳解
- js中top的作用深入剖析
- window.top[_CACHE]實現(xiàn)多個jsp頁面共享一個js對象
- JS獲取iframe中marginHeight和marginWidth屬性的方法
- JS中完美兼容各大瀏覽器的scrolltop方法
- js中不同的height, top的區(qū)別對比
相關(guān)文章
使用HTML+CSS+JS制作簡單的網(wǎng)頁菜單界面
這篇文章主要介紹了使用HTML+CSS+JS制作簡單的網(wǎng)頁菜單界面,這個ABROAD項目所使用的JavaScript部分代碼非常簡單,需要的朋友可以參考下2015-07-07JavaScript數(shù)據(jù)類型轉(zhuǎn)換
本文詳細(xì)講解了JavaScript實現(xiàn)數(shù)據(jù)類型轉(zhuǎn)換的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-03-03Javascript入門學(xué)習(xí)資料收集整理篇
為大家更好的接觸和學(xué)習(xí)js資料,所以我轉(zhuǎn)了這篇文章,我大約的看了下,文章寫的非常不錯,希望大家不要急,慢慢看,第一次看不懂不要緊,多練習(xí)就可以了2008-07-07JavaScript 學(xué)習(xí)筆記(九)call和apply方法
兩者實現(xiàn)的功能是完全一樣的,只是參數(shù)傳遞方式不一樣,call是將各個參數(shù)以逗號(,)隔開,而apply是將所有參數(shù)組成一個數(shù)組進(jìn)行傳遞。2010-01-01