HTML DOM id 屬性
定義和用法
id 屬性可設置或返回 iframe 的 id。
語法
iframeObject.id=id
實例
本例展示了兩種返回 iframe 的 id 的方法:
<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>