次のコードテストを次のように理解できます。
1.HTML:
次のようにコードコードをコピーします。
<
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<メタhttp-equiv = "content-type" content = "text /html; charset = gb2312" /> />
<Title>非文書</title>
</head>
<body>
<div> ===================================== /div>
<p id = "pox">親ウィンドウへのサブウィンドウアクセスの要素をテストするために使用</p>
<div> ==================== iframeセグメンテーションライン=============== = = </div>
<iframe src = "a.html" frameborder = "0" id = "framea" name = "framea"> </iframe>
<iframe src = "b.html" name = "iframeb" frameborder = "0" id = "frameb"> </iframe>
<div> ==================== iframeセグメンテーションライン=============== = = </div>
<p>最初に実証するために来てください:子ウィンドウの子のウィンドウにアクセスする方法または要素</p>
<p>概要:親ウィンドウのサブウィンドウにアクセスする方法は、別の方法と要素を採用しています</p>
<入力型= "button" onclick = "framediv()" value = "親ウィンドウの特定の要素は要素にアクセスします" /> /> />
<入力型= "ボタン" onclick = "framefun()" value = "親ウィンドウアクセスにアクセスする方法" /> /> />
<script type = "text/javascript">
// sub -window親ウィンドウメソッドへのアクセス
関数testp(ss){
アラート(SS)
}
// iframeの要素を取得します
関数getIframe(ID){
document.getElementByID(ID).ContentWindow.Document;
}
//父ウィンドウサブウィンドウ要素にアクセスします
関数framediv(){
getiframe( "framea")。
//window.frames ["iframea"] .getElementByIdmaidmaidmaidmaidss。
}
//父ウィンドウサブウィンドウメソッドにアクセスします
function framefun(){
//getiframe="frameb").getsfun(); //この形式のこの形式のメソッドにアクセスできません
// window.frames ["iframeb"]。
alert(window.frames ["iframeb"]。getSfun());
}
</script>
</body>
</html>
A.html
次のようにコードコードをコピーします。
<
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<メタhttp-equiv = "content-type" content = "text /html; charset = gb2312" /> />
<Title>非文書</title>
</head>
<body>
<div id = "ooxx">親ウィンドウの特定の要素をテストして、サブウィンドウの特定の要素にアクセスするために使用されます</div>
<p id = "divooxx">ウィンドウBの特定の要素をテストしてウィンドウにアクセスするために使用</p>
<p>1。sub-window iframea親ウィンドウの特定の要素にアクセス</p>
<入力型= "ボタン" onclight = "frametopdiv()" value = "sub -window親ウィンドウの特定の要素にアクセスする" /> />
<入力型= "ボタン" onclick = "frametopfun()" value = "親ウィンドウでアクセスする小さなウィンドウ" /> />
<script type = "text/javascript">
// sub -window親ウィンドウに特定の要素にアクセス
関数frametopdiv(){
parent.document.getElementByid( "Pox")。
parent.document.getElementById( "Pox")。
}
// sub -window親ウィンドウメソッドへのアクセス
関数frametopfun(ss){
parent.testp( "ssss");
}
// IFRAMEBアクセスをテストするために使用される方法
関数testba(){)
アラート( "iframebアクセスをテストする方法")
}
</script>
</body>
</html>
b.html
次のようにコードコードをコピーします。
<
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<メタhttp-equiv = "content-type" content = "text /html; charset = gb2312" /> />
<Title>非文書</title>
</head>
<body>
<p> 2:テストサブウィンドウの間でメソッドまたは要素をテスト</p>
<入力タイプ= "ボタン"値= "サブウィンドウbサブウィンドウの特定の要素にアクセス" onclick = "frametframediv()" /> />
<入力型= "ボタン"値= "サブウィンドウbサブウィンドウa" onclick = "frametframefun()" /> />のメソッドにアクセス
<script type = "text/javascript">
//サブウィンドウbサブウィンドウの特定の要素へのアクセス
関数frametframediv(){{
//parent.document.getElementById.com
//parent.document.getElementById.com
var _bframe = parent.getiframe( "framea");
_bframe.getElementById( "divooxx")。
_bframe.getElementById( "divooxx")。
}
//小さなウィンドウbサブウィンドウの方法へのアクセス
関数frametframefun(){{
window.parent.frames ["framea"]。
}
</script>
<script type = "text/javascript">
function getSfun(){
「ssssss」を返します。
}
// getFun()
</script>
</body>
</html>