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 = {
ทดสอบ: "จางซานผ่านไปที่หน้าต่างเด็ก"
ชนะ: หน้าต่าง
-
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; border: 5px solid #0000ff;"> </div>
<อินพุต type = "ปุ่ม" id = "btn" value = "Popup Subwindow">
</body>
</html>
เด็ก. 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 Pass
var args = window.dialogarguments;
var win = args.win; // เป็นประธานวัตถุหน้าต่าง
var content = document.getElementById ("เนื้อหา");
content.value = args.test;
var btn = document.getElementById ("btn");
btn.onclick = function () {
// กล่องโต้ตอบ Modal จะมีค่า
window.returnvalue = content.value;
window.close ();
-
-
</script>
</head>
<body>
<input type = "text" id = "content"> <input type = "button" id = "btn" value = "pass value ไปยังหน้าต่างหลัก">
</body>
</html