In struggling with a solution to this problem I’ve run into another, related issue: how can I determine what the location of a running script is? (no, it’s not document.location as that will tell you the location of the page including the script)
so, with:
– a.html –
<script type="text/javascript" src="/my/path/myscript.js"></script>
– myscript.js –
var myLoc = document.location; // what to use instead?
so the answer to this is two-fold: 1) if the script was loaded by a tag directly, one can use RightSaidFred’s approach consisting of picking up the last entry in the list of scripts, 2) for scripts that are loaded in a page that was loaded via ajax, the solution is the plugin at: Where are scripts loaded after an ajax call?