Categories
JavaScript Answers

How to get the URL of script being called with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *