Javascript DOM HTML Object type Property get

Introduction

Get the media type of the object:

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

Click the button to display the media type of the object.

View in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

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

</body>
</html>

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

The type attribute specifies the Internet media type of the object.

The type property returns a String representing the Internet media type of the embedded content.




PreviousNext

Related