Javascript Reference - HTML DOM Embed src Property








The src attribute from the embed element specifies the URL of the external file to embed.

The src property sets or gets the src attribute in an embed element.

Browser Support

src Yes Yes Yes Yes Yes

Syntax

Return the src property.

var v = embedObject.src

Set the src property.

embedObject.src=URL




Property Values

Value Description
URL Specifies the address (URL) of the external file to embed.

Return Value

A String type value representing the URL of the embedded file.

Example

The following code shows how to get the URL of an embedded file.

<!DOCTYPE html>
<html>
<body>
<embed id="myEmbed" src="http://example.com/notExist.swf">
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    var x = document.getElementById("myEmbed").src;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>