javascript - get node reference to script tag that calls a function
<p>How might one go about obtaining a reference to the DOM script tag that called a function?</p>

<p>For example:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    var globalfunc = function(){
        //obtain a reference to the script block that globalfunc() was called from
    }
&lt;/script&gt;

&lt;script type="text/javascript"&gt;
    globalfunc();
&lt;/script&gt;
</code></pre>

<p>I know that I could assign an id or class to the script element and pass that through to my function to do a DOM lookup, but I think it would be more flexible and elegant to do it without such a thing. The main reason is that I may have to do some work on our site to get 3rd party ads wrangled into shape, and we don't have control over the scripts they use to load their ads.</p>
