Javascript DOM HTML Object width Property get

Introduction

Get the width of an <object> element:

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

Click the button to display the width of the object element.

View in separate window

<!DOCTYPE html>
<html>
<body>

<object id="myObject" width="250" height="200" data="video.mp4"></object>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//  w  w w . ja  va  2  s. co  m
  var x = document.getElementById("myObject").width;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related