at first you have to find the name of script you want to download then search it on the current js file i hope it will working out some time its like \xxx\x\x.js i think don't have to explain more
AcevedoAaron, thank you for your reply, but I mean that for example I've included script.js file in index.html <script src="/dir/subdir/script.js" type="text/javascript"></script> and I want add a code in the script.js file which will alert /dir/subdir/script.js. I think now it is easier to understand what I want. Thank you.
You could give your script tag an id and then extract the src from it like this: <script type="text/javascript" id="myscript" src="/dir/subdir/script.js"></script> and in your script you could do: var my_location = document.getElementById('myscript').src; alert(my_location); my_location would then = "/dir/subdir/script.js"
Thank you for you replies, but ThePHPMaster, your example didn't do what I want and, shofstetter, I want to do by changing only the js file.
Sorry, just notice that you wanted the sub document URL and not the parent. If you have used PHP, Javascript is similar in their includes, except that you can not get the sub url but rather the main one. The only solution is to do what shof said, even in the sub file (included script.js): alert(document.getElementById('myscript').src); Code (markup): As long as that object has an ID, you can track it on any Javascript on that page.