HTML | DOM Object data Property
The HTML | DOM Object data Property is used to set or return the value of the data attribute of an <object> element. The data attribute is used to specify the URL of the resource which will be used by the object.
Syntax:
- Return the data property.
objObject.data
- It is used to set the data property.
objObject.data = URL
Property Values: It contains the value i.e URL which specifies the URL of the resource.
- Absolute URL: It is used to point another website.
- Relative URL: It points to link within a website.
Example: This Example returns a data Property.
<!DOCTYPE html> <html> <body> <center> <object id="myobject" data="HelloGeeks.swf" width="400" height="100" name="myGeeks" form="myGeeks" data= </object> <h2>DOM Object data Property</h2> <button onclick="Geeks()"> Click it </button> <p id="gfg" style="color:green; font-size:25px;"> </p> </center> <script> function Geeks() { // Accessing Object element. var x = document.getElementById( "myobject").data; document.getElementById( "gfg").innerHTML = x; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera
Recommended Posts:
- HTML | <object> data Attribute
- HTML | DOM Object name Property
- HTML | DOM Object Height Property
- HTML | DOM Object width Property
- HTML | DOM Object form Property
- HTML | DOM Object type Property
- HTML | DOM InputEvent data Property
- CSS | The object-fit Property
- CSS | object-position Property
- HTML | DOM Object Object
- How to remove a property from JavaScript object ?
- JavaScript | Get the index of an object by its property.
- HTML | DOM li Object
- HTML | DOM Ul Object
- HTML | DOM BR Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



