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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.