Parent.hmtl
Salinan kode adalah sebagai berikut:
<! Doctype html public "-// w3c // dtd html 4.01 transisi // en" "http://www.w3.org/tr/html4/loose.dtd">
<Html>
<head>
<meta http-equiv = "konten tipe" content = "text/html; charset = utf-8">
<Title> jendela induk </iteme>
<type skrip = "Teks/JavaScript">
window.onload = function () {
var btn = document.getElementById ("btn");
btn.onClick = function () {
var obj = {
Tes: "Zhang San masuk ke jendela anak",
Menang: Jendela
};
var returnValue = window.showmodaldialog ("child.html", obj, "Dialogleft: 100px; dialogtop: 100px; dialogwidth: 400px; dialogheight: 300px; dapat diatasi: ya");
if (returnValue! = null) {
document.geteLementById ("konten"). innerHtml = returnValue;
}
};
}
</script>
</head>
<body>
<Div id = "content" style = "margin: 50px; lebar: 100px; tinggi: 150px; Border: 5px solid #0000ff;"> </div>
<input type = "tombol" id = "btn" value = "subwindow popup">
</body>
</html>
Child.html
Salinan kode adalah sebagai berikut:
<! Doctype html public "-// w3c // dtd html 4.01 transisi // en" "http://www.w3.org/tr/html4/loose.dtd">
<Html>
<head>
<meta http-equiv = "konten tipe" content = "text/html; charset = utf-8">
<title> sub jendela </iteme>
<type skrip = "Teks/JavaScript">
window.onload = function () {
// Dapatkan parameter URL Pass
var args = window.dialogarguments;
var win = args.win; // objek jendela ketua
var content = document.getElementById ("content");
content.value = args.test;
var btn = document.getElementById ("btn");
btn.onClick = function () {
// Kotak dialog modal akan memiliki nilainya
window.ReturnValue = Content.Value;
window.close ();
}
}
</script>
</head>
<body>
<input type = "text" id = "content"> <input type = "Tombol" id = "btn" value = "nilai lulus ke jendela induk">
</body>
</html