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 ينتقل إلى نافذة الطفل" ،
فوز: نافذة
} ؛
var returnvalue = window.showmodaldialog ("child.html" ، obj ، "dialogleft: 100px ؛ dialogtop: 100px ؛ dialogwidth: 400px ؛ dialogheight: 300px ؛ resizable: نعم") ؛
if (returnValue! = null) {
document.getElementById ("المحتوى"). innerhtml = returnValue ؛
}
} ؛
}
</script>
</head>
<body>
<div id = "content" style = "margin: 50px ؛ width: 100px ؛ الارتفاع: 150px ؛ الحدود: 5px solid #0000ff ؛"> </div>
<type type = "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
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>
<type type = "text" id = "content"> <input type = "button" id = "btn" value = "pass value to parent window">
</body>
</html