เช่นวิธี:
document.frames ['MyFrame']
วิธี Firefox:
document.getElementById ('myFrame')
เช่นวิธี Firefox:
คัดลอกรหัสรหัสดังนี้:
ฟังก์ชั่น getValue () {
var tmp = '';
if (document.frames) {
tmp += 'เช่นพูดว่า:';
tmp += document.frames ['myframe']
} อื่น {
tmp = document.getElementById ('myFrame')
-
การแจ้งเตือน (TMP);
-
รหัสตัวอย่าง:
รหัสในหน้า a.html
คัดลอกรหัสรหัสดังนี้:
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title>
JavaScript ได้รับการทดสอบค่าขององค์ประกอบในหน้าใน iframe
</title>
</head>
<body>
<iframe id = "myFrame" src = 'b.html'> </iframe>
<อินพุต type = "ปุ่ม" id = "btn" onclick = "getValue ()" value = "ทดสอบ">
<script type = "text/javascript">
ฟังก์ชั่น getValue () {
var tmp = '';
if (document.frames) {
tmp += 'เช่นพูดว่า:';
tmp += document.frames ['myframe']
} อื่น {
tmp = document.getElementById ('myFrame')
-
การแจ้งเตือน (TMP);
-
</script>
</body>
</html>
รหัสในหน้า b.html
คัดลอกรหัสรหัสดังนี้:
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title>
ฉันเป็นหน้าใน iframe
</title>
</head>
<body>
<อินพุต type = 'text' id = "test" value = 'ยินดีต้อนรับสู่การเยี่ยมชม: justflyhigh.com'>
</body>
</html>