I have some javascript code on one webapp that is being included on an html in another webapp. Server: ServerOne Filename: includeme.js Contents: code: alert('inside includeme.js'); Server: ServerTwo Filename: testpage.html Contents: code: <script src="/webapps/ServerOne/scripts/includeme.js"> The page is rendered when a user types the following into a browser: http://ServerName/webapps/ServerTwo/pages/testpage.html which includes the contents of "includeme.js". I am wondering if it is possible from the javascript inside "includeme.js" to parse the URL that was used to include it code: <script src="/webapps/ServerOne/scripts/includeme.js"> and extract the word "ServerOne" from the URL. I know this is a strange requirement, and there are a lot of workarounds but I am wondering if the javascript can get ahold of the URL used to include it. Thanks, Jim
document.location.href Actually in this case it won't, because the javascript document.location.href refers to the current window. To solve this problem, I was able to give the <script> tag an id and then reference this tag via document.getElementById('scriptTagId') and print out the ".src". attribute of the <script> tag.