1

location.href gives me the URL of the page I'm on. The page contains this:

<script src="http://mydomain/myscript.js"></script> 

Inside of myscript.js is there a property that gives me the script URL ("http://mydomain/myscript.js")?

1

1 Answer 1

0

I don't know what you mean, but i think that you want to find the src of all scripts. I found this to work:

 let array_of_src=[]
 document.querySelectorAll('script').forEach(function(element){array_of_src.push(element.src)})
 //do stuff with the array of all the srcs
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.