0

Possible Duplicate:
How might I get the script filename from within that script?
JavaScript - How do I get the URL of script being called?

How, within my javascript code, can I determine the URL the javascript was loaded from, e.g. if I have a page http://www.example.com/index.html

<html>
<script src='/code/whereami.js'></script>
...

Then my javascipt would be loaded from http://www.example.com/code/whereami.js but how do find this URL from within the code?

(yes, by definition, as the programmer, I should know where my files are - the point of the exercise here is to verify the integrity of the resulting page)

Community
  • 1
  • 1
symcbean
  • 47,736
  • 6
  • 59
  • 94
  • i guess u can get that from meta type and not url ??! – sree May 18 '12 at 16:28
  • The proposed duplicates do provide a limited solution: but rely on the script beig executed sychrnously with its declaration - which is not exactly ideal. – symcbean May 18 '12 at 19:24

0 Answers0