1. เพจย่อยคือสถานการณ์ที่เพจหลักปรากฏขึ้นผ่าน window.open
หากเพจย่อยต้องการส่งค่าไปยังเพจหลัก เพียงเพิ่ม window.opener ที่ด้านหน้าเอกสาร
ชอบ:
1. รหัสหน้าหลัก:
<html xmlns="http://www.w3.org/1999/xhtml">
<หัว>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ชื่อเอกสารที่ไม่มีชื่อ>
หัว>
<ภาษาสคริปต์ = "จาวาสคริปต์">
ฟังก์ชั่นทันจู()
-
window.open("ไม่มีชื่อ-5.html");
-
สคริปต์>
<ร่างกาย>
<form id="form1" name="form1" method="post" action="">
<ฉลาก> <ประเภทอินพุต = "ส่ง" ชื่อ = "ปุ่ม" id = "ปุ่ม" ค่า = "ส่ง"
onclick="tanchu()" />
label> <label> <input type="text" name="textfield" id="textfield" />
ฉลาก>
แบบฟอร์ม>
</ร่างกาย>
</html>
2. รหัสหน้าย่อย:
<html xmlns="http://www.w3.org/1999/xhtml">
<หัว>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ชื่อเอกสารที่ไม่มีชื่อ>
หัว>
<ภาษาสคริปต์ = "จาวาสคริปต์">
ฟังก์ชั่น aaa()
-
window.opener.document.getElementByIdx('textfield').value='123123123';
-
สคริปต์>
<ร่างกาย>
<form id="form1" name="form1" method="post" action="">
<ฉลาก> <ประเภทอินพุต = "ส่ง" ชื่อ = "ปุ่ม" id = "ปุ่ม" ค่า = "ส่ง"
onclick="aaa()" />
ฉลาก>
แบบฟอร์ม>
</ร่างกาย>
</html>
2. หน้าย่อยคือสถานการณ์หน้าในเฟรม iframe
หากเพจย่อยต้องการส่งค่าไปยังเพจหลัก เพียงเพิ่มพาเรนต์ไว้ด้านหน้าเอกสาร
1. รหัสเพจหลัก:
<html xmlns="http://www.w3.org/1999/xhtml">
<หัว>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ชื่อเอกสารที่ไม่มีชื่อ>
หัว>
<ร่างกาย>
<form id="form1" name="form1" method="post" action="">
<label> <input type="text" name="textfield" id="textfield" />
ฉลาก>
<iframe id="myiframe" src="Untitled-3.html">iframe>
แบบฟอร์ม>
</ร่างกาย>
</html>
2. รหัสหน้าย่อย
<html xmlns="http://www.w3.org/1999/xhtml">
<หัว>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ชื่อเอกสารที่ไม่มีชื่อ>
หัว>
<ภาษาสคริปต์ = "จาวาสคริปต์">
ฟังก์ชั่น AA()
-
var a=parent.document.getElementByIdx('textfield').value;
การแจ้งเตือน (ก);
-
สคริปต์>
<ร่างกาย>
<form id="form1" name="form1" method="post" action="">
<ฉลาก> <ประเภทอินพุต = "ส่ง" ชื่อ = "ปุ่ม" id = "ปุ่ม" ค่า = "ส่ง"
onClick="aa()" />
ฉลาก>
แบบฟอร์ม>
</ร่างกาย>
</html>