The HTML DOM Object Object in HTML represents the <object> element.
Creating an <object> element
var objectElement = document.createElement(“OBJECT”)
Here, “objectElement” can have the following properties −
Property | Description |
---|---|
data | Itsets/returns the URL of the resource being used by the objectelement |
form | Itreturns a reference to the enclosing form of the object element |
height | Itsets/returns the height of the object element |
name | Itsets/returns the name of the object element |
type | Itsets/returns the content type for data downloaded via the dataattribute |
useMap | Itsets/returns the name of a client-side image map to be used withthe object element |
width | Itsets/returns the width of the object element |
Let us see an example of HTML DOM Object Object property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM Object object</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style></head> <body> <form> <fieldset> <legend>HTML-DOM-Object-Object</legend> <object id="objSelect" height="200" data="https://www.tutorialspoint.com/spring/images/spring-mini-logo.jpg"></object> <input type="button" onclick="getObjectData()" value="Get URL"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var objSelect = document.getElementById("objSelect"); function getObjectData() { objSelect.data divDisplay.textContent = 'URL of above picture: '+objSelect.data; } </script> </body> </html>
Output
Before clicking ‘Get URL’ button −
After clicking ‘Get URL’ button −