Run javascript code from applet
Sometimes you may want your applet to interact with javascript.
Apply this code to your applet class.
private void alert(){
try{
getAppletContext().showDocument(
new URL("javascript:doAlert()"));
}catch (MalformedURLException ex) { }
}
When running this code you'll execute the javascript doAlert() placed in the htm file where the <applet> tag is located.
<script language="javascript" type="text/javascript">
function doAlert() {
//some code to be executed...
alert('doAlert() exevcuted!');
}
</script>