Re: Compiling <script> src into a function

"Igor Tandetnik" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
Mohan <[email protected]> wrote:
> I would like to know if there is a mechanism to compile the script
> code from the "src" attribute of the <script> tag into a function that
> can be later invoked from my JS code. For eg:
> 
> <script src="some.url">
> Now this if the source script compiles to a function say "foo", then I
> would like to execute the script by calling foo();

I suppose you could download the text from some.url using XMLHttpRequest, then surround it with "function myfunc() {" and "}", and finally eval() the whole thing.

Igor Tandetnik
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.