Calling Javascript Functions from a Java Applet

I have a Java applet in an HTML page. I need the applet to call a specific Javascript function to notify the HTML page of some events.

I am currently calling a JavaScript function:

getAppletContext().showDocument(new URL("javascript:window.notifyEvent("+msisdn+")")); 

I define a valid function inside the HTML, but when the applet really calls it, I get an Uncaught ReferenceError: notifyEvent is not defined error.

Where do I need to define a javascript function for an applet to be able to call it?

Thanks!

+6
source share
2 answers

For this you must use JSObject . It was a long time ago, although I heard that there are still differences between browsers. Therefore, if you need to support many browsers, I would suggest checking your supported set as soon as you see that it works in one.

The bridge between the Java applet and the text input elements on the web page

+3
source

Source: https://habr.com/ru/post/910591/


All Articles