HTML | DOM Embed Object
The Embed Object in HTML DOM is used to represent the <embed> element. The <embed> element can be accessed by using getElementById() method.
Note: This object is new in HTML 5.
Property Values:
- height: It sets or returns the value of the height attribute.
- src: It sets or returns the value of the src attribute of an Embed Object,
- type: It sets or returns the value of the type attribute of an Embed Object.
- width: It sets or returns the value of the width attribute of an Embed Object.
Syntax:
document.getElementById("ID");
Where ID assigned to the <embed> tag.
Example 1: This example describes the getElementById() method to access the <embed> element.
<!DOCTYPE html> <html> <head> <title> HTML DOM Embed Object </title> </head> <body> <h1>GeeksForGeeks</h1> <h2>DOM Embed Object</h2> <p> <q style = "color:green; font-style:italic;"> GeeksforGeeks </q> is loading. </p> <embed id = "GFG" src = "loading2.swf" type="application/x-shockwave-flash"> <br><br> <button onclick = "myGeeks()">Submit</button> <p id = "sudo"></p> <script> function myGeeks() { var source = document.getElementById("GFG").src; document.getElementById("sudo").innerHTML = source; } </script> </body> </html> |
Output:
Before Click on the Button:

After Click on the Button:

Example 2: Embed Object can be created by using the document.createElement Method.
<!DOCTYPE html> <html> <head> <title> HTML DOM Embed Object </title> </head> <body style="text-align:center"> <h1>GeeksForGeeks</h1> <h2>DOM Embed Object</h2> <button onclick = "myGeeks()"> Submit </button> <p id = "sudo"></p> <script> function myGeeks() { var g = document.createElement("EMBED"); g.setAttribute("src", "loading2.swf"); document.body.appendChild(g); } </script> </body> </html> |
Output:
Before Click on the Button :

After Click on the Button:

Supported Browsers: The browser supported by DOM Embed Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <embed> Tag
- HTML | DOM Embed src Property
- HTML | <embed> src Attribute
- HTML | <embed> height Attribute
- HTML | DOM embed height property
- HTML | <embed> type Attribute
- HTML | <embed> width Attribute
- HTML | DOM embed width property
- HTML | DOM embed type property
- HTML | DOM Object Object
- HTML | DOM Bdo Object
- HTML | DOM Div Object
- HTML | DOM DD Object
- HTML | DOM li Object
- HTML | DOM Map Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

