Open In App
Related Articles

HTML | DOM Embed src Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The HTML DOM Embed src Property is used to set or return the value of the src attribute in an embed element. This attribute specifies the address of the external file to embed.

Syntax:

  • Return the src property:
    embedObject.src
  • Set the src property:
    embedObject.src = URL

Property Values:

  • URL: Specify the URL of the external file to embed.
    Possible Value:

    • Absolute URL: points to another web site
    • relative URL: points to a file within a web site.

    Return Value: A String which is represent the URL of the embedded file. Returns the entire URL with the protocol.

    Example:




    <!DOCTYPE html>
    <html>
      
    <head>
        <title>HTML DOM Embed src Property</title>
    </head>
      
    <body>
        <center>
            <h1 style="color:green">
              GeeksforGeeks
          </h1>
            <embed id="embedID" 
                   src="https://ide.geeksforgeeks.org">
            <br>
            <button onclick="GFGfun()">
              Try it
          </button>
      
            <p id="pid"></p>
      
            <script>
                function GFGfun() {
                    var idsrc = document.getElementById("embedID").src;
                    document.getElementById("pid").innerHTML = idsrc;
                }
            </script>
        </center>
    </body>
      
    </html>

    
    

    Output:

    Supported Browsers: The browsers supported by HTML DOM Embed src Property are listed below:

    • Google Chrome 1 and above
    • Edge 12 and above
    • Internet Explorer 6 and above
    • Firefox 1 and above
    • Apple Safari 4 and above
    • Opera 12.1 and above

    Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

    Last Updated : 21 Jul, 2022
    Like Article
    Save Article
    Previous
    Next
Similar Reads
Complete Tutorials