HTML DOM id 屬性
定義和用法
id 屬性可返回框架的 id。
語法
frameObject.id=id
實例
在我們的例子中,首先將創(chuàng)建包含帶有兩個列的框架集的 HTML 文檔。每列設置為瀏覽器窗口的 50%:
<html> <frameset cols="50%,50%"> <frame id="leftFrame" src="frame_id.htm"> <frame id="rightFrame" src="frame_a.htm" > </frameset> </html>
HTML 文檔 "frame_id.htm" 被放入第一列,而 HTML 文檔 "frame_a.htm" 被放入第二列。
下面是 "frame_id.htm" 的源代碼:
<html>
<body>
<script type="text/javascript">
x=parent.document.getElementsByTagName("frame")[0];
y=parent.document.getElementsByTagName("frame")[1];
document.write("The id for the left frame is: ");
document.write(x.id);
document.write("<br />The id for the right frame is: ");
document.write(y.id);
</script>
</body>
</html>