parent.hmtl
コードコピーは次のとおりです。
<!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">
window.onload = function(){
var btn = document.getElementById( "btn");
btn.onclick = function(){
var obj = {
テスト:「Zhang SanがChild Windowに移ります」、
勝利:ウィンドウ
};
var returnValue = window.showmodaldialog( "child.html"、obj、 "dialogleft:100px; dialogtop:100px; dialogwidth:400px; dialogheight:300px; resizable:yes");
if(returnValue!= null){
document.getElementById( "content")。innerhtml = returnValue;
}
};
}
</script>
</head>
<body>
<div id = "content" style = "マージン:50px;幅:100px; height:150px; border:5px solid#0000ff;"> </div>
<入力型= "button" id = "btn" value = "Popup subwindow">
</body>
</html>
child.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">
window.onload = function(){
// URLパスパラメーターを取得します
var args = window.dialogarguments;
var win = args.win; // windowオブジェクトを司会します
var content = document.getElementById( "content");
content.value = args.test;
var btn = document.getElementById( "btn");
btn.onclick = function(){
//モーダルダイアログボックスには値があります
window.returnvalue = content.value;
window.close();
}
}
</script>
</head>
<body>
<入力型= "text" id = "content"> <入力タイプ= "ボタン" id = "btn" value = "pass value to parent window">
</body>
</html