Object data Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Object

Description

The data property sets or gets the data attribute of an <object> element, which sets the URL of the resource used by the object element.

Set the data property with the following Values

Value Description
URL Sets the URL of the resource to be used by the object.

Return Value

A String, representing the URL of the object.

The following code shows how to get the URL of the object:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<object id="myObject" width="250" height="200" data="helloworld.swf"></object>

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

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

<script>
function myFunction() {/*w  w  w  .  j av  a 2 s .  com*/
    var x = document.getElementById("myObject").data;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials