How can I find the *script* element where my JavaScript is d

For a fragment of HTML/JavaScript that gets loaded into a host web page dynamically, I need the JavaScript fragment to know about where it is declared. Is there a way of finding the tag that the currently executing JavaScript was loaded from?The HTML fragment is loaded from the same host as the current page using a jQuery ajax …

via HTML Language Development » Search Results » ajax:

How can I find the *script* element where my JavaScript is d

For a fragment of HTML/JavaScript that gets loaded into a host web page dynamically, I need the JavaScript fragment to know about where it is declared. Is there a way of finding the tag that the currently executing JavaScript was loaded from?
The HTML fragment is loaded from the same host as the current page using a jQuery ajax call and inserting the result into the DOM.
Edit:
What I really am trying to do, and the above would be one potential way of implementing it, is to have a fragment of HTML/JavaScript being loaded dynamically and a known initialization function be called by the host page with some parameters. Any portable solution that would allow for the worlds to meet would solve my problem.
…………………………..

You may use id attribute for your script tag and find it by #mylib selector or find it using tag&attr selector script[src=”mylib.js”].

For more info: How can I find the *script* element where my JavaScript is d

HTML Language Development » Search Results » ajax

How can I find the *script* element where my JavaScript is d

Share this post:

Related Posts

Leave a Comment