Sometimes, we want to get the URL of script being called with JavaScript.
In this article, we’ll look at how to get the URL of script being called with JavaScript.
How to get the URL of script being called with JavaScript?
To get the URL of script being called with JavaScript, we can use the document.currentScript
property.
For instance, we write
console.log(document.currentScript);
to log the value of the current script element being run.
Conclusion
To get the URL of script being called with JavaScript, we can use the document.currentScript
property.