Embed src Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Embed

Description

The src property sets or gets the src attribute in an embed element, which controls the address (URL) of the external file to embed.

Set the src property with the following Values

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

Possible values:

  • An absolute URL - like src="http://www.example.com/hello.swf"
  • A relative URL - like src="hello.swf"

Return Value

A String, representing the URL of the embedded file.

The following code shows how to return the URL of an embedded file:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<embed id="myEmbed" src="helloworld.swf">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  www  . j  ava  2  s  .co m*/
    var x = document.getElementById("myEmbed").src;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials