In various scenarios, it becomes necessary to reference the script tag that loaded the currently executing script. This can be achieved through multiple methods, each with its own advantages and drawbacks.
<script><br>var me = document.currentScript;<br></script><br>
Benefits:
Problems:
function isMe(scriptElem){</p> <div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">if( isMe(scripts[i])){ me = scripts[i]; }
}
Benefits:
Problems:
<script><br>var scripts = document.getElementsByTagName( 'script' );<br>var me = scripts[ scripts.length - 1 ];<br></script><br>
Benefits:
Problems:
The above is the detailed content of How to Find the Script Tag That Loaded the Current Script?. For more information, please follow other related articles on the PHP Chinese website!