Getting the currently executing, dynamically appended, script tag [duplicate]

Possible Duplicate:
How may I reference the script tag that loaded the currently-executing script?

Is there any way to get a reference to the currently running script element if it was appended dynamically after page load? The answers to this question do not work as I do not know the tag ID and the [scripts.length-1] method fails when multiple tags have been appended in succession.



Since the executing script presumably "knows" the name it was loaded with the following should work:

for (var s, scripts = document.getElementsbyTagName ('script'), i = scripts.length; i--;)
  if ((s = scripts[i]).src.indexOf ('scriptname.js') < 0 && && !test ( {
     alert ("Script " + s.src + " id " + + " not yet processed");


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.