Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Script src Property

  • Last Updated : 03 Jun, 2019

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.


  • It return the src property:
  • 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>
        DOM script src Property
<body style="text-align:center;">
        DOM script src property
    <script id="myGeeks"
    <button onclick="Geeks()">Submit</button>
    <h2 id="demo"></h2>
        function Geeks() {
            var x = document.getElementById(
              "demo").innerHTML = x;


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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :