Javascript DOM HTML Object data Property get

Introduction

Get the URL of the object:

var x = document.getElementById("myObject").data;

Click the button to display the URL of the object.

View in separate window

<!DOCTYPE html>
<html>
<body>

<object id="myObject" width="200" height="200" data="video.mp4"></object>

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

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

<script>
function myFunction() {//from   www .  j  a  v  a 2 s.  c o m
  var x = document.getElementById("myObject").data;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The data property sets or gets the value of the data attribute of an <object> element.

The data attribute sets the URL of the resource for the object element.

The data property accepts and returns a String type value.




PreviousNext

Related