HTML DOM id โครงการ
การระบุและการใช้งาน
id โครงการสามารถตั้งค่าหรือกลับค่า id ของ iframe
รูปแบบ
iframeObject.id=id
ตัวอย่าง
ตัวอย่างนี้แสดงวิธีการที่จะกลับไปที่ id ของ iframe สองวิธี
<html> <body> <iframe src="frame_a.htm" id="frame1"></iframe> <br /><br /> <script type="text/javascript"> document.write("The iframe's id: "); document.write(document.getElementsByTagName("iframe")[0].id
); document.write("<br /><br />"); document.write("An alternate way: "); document.write("<br />"); document.write("The iframe's id: "); document.write(document.getElementById("frame1").id
); </script> </body> </html>