Script src Property
Example
Get the URL of an external script:
var x = document.getElementById("myScript").src
x The output is:
http://www.w3cschool.cc/jsref/demo_script_src.js
Try it »
Definition and Usage
The src property sets or returns the value of the src attribute of the script.
The src property specifies the URL of the external script file.
If you want to run the same JavaScript on multiple pages of a website, you should create an external JavaScript file instead of repeatedly writing the same script. Save the script file with the .js extension, and then in the
Script Object