Open In App

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: 

objObject.data
objObject.data = URL

Property Values: It contains the value i.e URL which specifies the URL of the resource. 



Return Value: It returns a String that represents the object URL. Returns the full URL, including the protocol (like http://)

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() {
 
            // return object data type Property
            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: 


Article Tags :