Mohan
2009-10-28 22:40:38 UTC
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
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