HTML DOM Object type Property

HTMLWeb DevelopmentFront End Technology

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

 Live Demo

<!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

Click the button to display the type −

raja
Published on 21-Jun-2019 13:39:40
Advertisements