HTML | DOM Script src Property
The DOM Script src Property is used to set or return the value of the src attribute of an <script> element. The src attribute specifies the URL of the External Javascript file.
Syntax:
- It return the src property:
scriptObject.src
- It is used to set the src property:
scriptObject.src = URL
Property Values: It contains the value i.e URL which specifies the URL of the External Javascript File.
Two Types of URL:
- An Absolute URL: It points to another website.
- A relative URL: it points to a file within the websites.
Return Value: It returns a string value which represents the URL of the External Javascript File.
Example: This Example returns the src Property.
<!DOCTYPE html> <html> <head> <title> DOM script src Property </title> </head> <body style="text-align:center;"> <h1> GeeksForGeeks </h1> <h2> DOM script src property </h2> <script id="myGeeks" type="text/javascript" src="my_script.js"> </script> <br> <button onclick="Geeks()">Submit</button> <h2 id="demo"></h2> <script> function Geeks() { var x = document.getElementById( "myGeeks").src; document.getElementById( "demo").innerHTML = x; } </script> </body> </html> |
output:
Before Clicking On Button :
After Clicking On Button :

Supported Browsers: The browsers supported by HTML | DOM Script src Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | DOM Script charset Property
- HTML | DOM Script async Property
- HTML | DOM Script type Property
- HTML | DOM Script text Property
- HTML | DOM Script defer Property
- HTML | script Tag
- HTML | <script> src Attribute
- HTML | DOM Script Object
- HTML | <script> type Attribute
- HTML | <script> charset Attribute
- HTML | DOM Bdo dir Property
- HTML | DOM li value Property
- HTML | DOM value Property
- HTML | DOM dir Property
- HTML | DOM specified Property
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.



