親フォームはiframeを取得します
window.iframeid
iframeは親ウィンドウを取得します
window.parent
parent.html
コードコピーは次のとおりです。
<!doctype html public " - // w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<Title>タイトルを挿入して</title>
<script type = "text/javascript">
関数btnfn(){
window.subwin.test();
}
関数get(name){
document.getElementById(name)を返します。
}
</script>
</head>
<body>
<入力id = "name" type = "text" value = "222">
<入力型= "button" id = "btn" value = "クリック" onclick = "btnfn();"> <br/>
<br/> <br/>
<iframe src = "sub.html" id = "subwin"
name = "subwin" marginwidth = "0"
marginheight = "0"スクロール= "yes" frameborder = "0" valign = "middle"
resize = "no" style = "display:block; border:3px solid red;"> </iframe>
</body>
</html>
sub.html
コードコピーは次のとおりです。
<!doctype html public " - // w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<Title>タイトルを挿入して</title>
<script type = "text/javascript">
function test(){
alert(window.parent.get( "name")。値); // result:222
}
</script>
</head>
<body>
私はフォームの内容です
</body>
</html>