First, why did you change the title of my post and added your unrelated question there?
Second, in PHP, PHP_SELF doesn't send the name of the actual php script in which it is called but the page running in the browser, i.e. if you call PHP_SELF from a file included in your index.php, PHP_SELF will return index.php, and not the name of the file you are actually calling it from. I think it's the same in JavaScript, you can't get the name of the actual JS file (I am not 100% sure), but you can get the URL of the page with document.location.href. On Aug 26, 2:06 pm, tinker <tinker.kicks....@gmail.com> wrote: > Hi there, > > I wish to get the path and filename of the current running js file > itself. I thought there must be the similar way just like php's > $_SERVER['PHP_SELF'] does but I cannot find any clue. As you know, > 'location' returns path and filename of html file not js file. Anyone > knows how to do that? I have been stuck by this question for weeks. I > wait for good answer. Thank you. > > Tink