Javascript DOM HTML Object Object get

Introduction

The Object object represents an HTML <object> element.

We can access an <object> element via document.getElementById():

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

Click the button to get the URL of the embedded flash file.

View in separate window

<!DOCTYPE html>
<html>
<body>
<object id="myObject" width="400" height="400" data="video.mp4">
</object>/*from  w w  w  . j  a  v a 2 s . c o  m*/
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
  var x = document.getElementById("myObject").data;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related