HTML DOM id-attribut

Definition och användning

id-attributet kan ställas in eller returnera id:n för ett iframe.

Syntaks

iframeObject.id=id

Exempel

Detta exempel visar två sätt att returnera id:n för ett 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("En annan metod: ");
document.write("<br />");
document.write("The iframe's id: ");
document.write(document.getElementById("frame1").id);
</script>
</body>
</html>