The HTML DOM Object data property returns a string corresponding to the value of the attribute data.
Following is the syntax −
Returning string value
ObjectElement.data
Set data property to a string value
ObjectElement.data = URLString
Let us see an example of HTML DOM Object data property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM Object data</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-data</legend> <object id="objSelect" height="200" data="https://www.tutorialspoint.com/python_blockchain/images/python-blockchain-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 −