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:
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 >w3wiki</ h1 > < h2 >DOM Embed Object</ h2 > < p > < q style = "color:green; font-style:italic;" > w3wiki </ q > is loading. </ p > < embed id = "GFG" src = "loading2.swf" type = "application/x-shockwave-flash" > < br >< br > < button onclick = "myBeginner()" >Submit</ button > < p id = "sudo" ></ p > < script > function myBeginner() { 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 >w3wiki</ h1 > < h2 >DOM Embed Object</ h2 > < button onclick = "myBeginner()" > Submit </ button > < p id = "sudo" ></ p > < script > function myBeginner() { 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