Applet to browser dynamic JavaScript

Q

Qu0ll

Perhaps slightly OT... is it possible for a Java applet to invoke the
surrounding browser's JavaScript engine to execute a dynamically generated
script? That is, not by using something like Rhino but just the browser's
ability to run scripts itself?

--
And loving it,

-Q
_________________________________________________
(e-mail address removed)
(Replace the "SixFour" with numbers to email me)
 
Q

Qu0ll

Randy Webb said:
Qu0ll said the following on 1/23/2008 6:54 AM:
Perhaps slightly OT... is it possible for a Java applet to invoke the
surrounding browser's JavaScript engine to execute a dynamically
generated script? That is, not by using something like Rhino but just
the browser's ability to run scripts itself?

function executeJSCode(codeToExecute){
if (document &&
document.createElement &&
document.appendChild &&
document.getElementsByTagName)
{
var newScript = document.createElement('script');
newScript.type = "text/javascript";
newScript.text = codeToExecute;
document.getElementsByTagName('head')[0].appendChild(newScript);
}
}

Thanks very much Randy.
Then you simply have to figure out how to get the Java applet to call
executeJSCode and pass it the string of script you want executed.

The Java part I can handle. It's just the JavaScript itself I wasn't sure
of or if it could be done.

--
And loving it,

-Q
_________________________________________________
(e-mail address removed)
(Replace the "SixFour" with numbers to email me)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top