Compiling <script> src into a function
Mohan <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <2b6fad8d-19d7-4a8b-9915-ddf262f1fbf0@n35g2000yqm.googlegroups.com> |
Hi All, 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 have tried to make changes to the nsJSContext::EvaluateString() method in nsJSEnvironment.cpp to compile it to a function using JS_CompileUCFunction. When I later use the compiled function in a JS code, it does not work. I then used JS_CallFunction() in nsJSEnvironment.cpp on my compiled function and the script executed, but is it possible to achieve the above functionality from within the JS code. I am sure I am missing something. Could anyone suggest some pointers and/or modifications that may be required? Regards, mohan