Skip to content
Related Articles

Related Articles

HTML | DOM Embed Object
  • Last Updated : 06 Feb, 2019
GeeksforGeeks - Summer Carnival Banner

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

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :