Computer >> Computer tutorials >  >> Programming >> HTML

HTML DOM Object type Property


The HTML DOM Object type Property is used to set or return the value of the type attribute of an object. However, the type attribute is used to set the media type like the object.

Following is the syntax to set the type property −

obj.type = type_of_media

Above, type_of_media is the standard media type, for example, image/bmp, image/tiff, image/tff, etc.

Following is the syntax to return the type property −

obj.type

Let us now see an example to implement the DOM Object type property −

Example

<!DOCTYPE html>
<html>
<body>
<object id="obj" width="450" height="200"
data="https://www.tutorialspoint.com/flex/samples/CSSApplication.swf"
type="application/vnd.adobe.flash-movie"></object>
<button onclick="display()">Display the media type</button>
<p id="pid"></p>
<script>
function display() {
   var x = document.getElementById("obj").type;
      document.getElementById("pid").innerHTML = x;
}
</script>
</body>
</html>

Output

HTML DOM Object type Property

Click the button to display the type −

HTML DOM Object type Property