HTML DOM
HTML DOM embeds Collection
The embeds collection returns an HTMLCollection of all <embed> elements in the current document. It is a live, read-only collection.
Definition and Usage
document.embeds returns an HTMLCollection listing every <embed> element on the page, in source order. The collection is live, so it stays in sync as <embed> elements are added or removed. document.plugins is an alias for the same collection.
Syntax
document.embedsAccess an item with document.embeds[index] and count items with document.embeds.length.
Example
<embed src="movie.mp4" type="video/mp4">
<embed src="song.mp3" type="audio/mpeg">
<p id="out"></p>
<script>
const embeds = document.embeds;
let text = "Embeds found: " + embeds.length + "<br>";
for (let i = 0; i < embeds.length; i++) {
text += embeds[i].src + "<br>";
}
document.getElementById("out").innerHTML = text;
</script>The script reports a length of 2 and lists the src of each <embed>. Only <embed> elements are included - <object>, <iframe>, and <video> are not part of this collection.
document.embeds and its alias document.plugins reflect only <embed> tags. Modern pages usually use <video>, <audio>, and <iframe> instead of <embed>.
