title: How to register a JavaScript callback in a Java Applet?
body: <p>I'm developing an invisible Java Applet, that will be controlled entirely from JavaScript.</p>
  
  <p>I can call the applet's Java methods easily, and I can call JavaScript methods from within the applet by using <code>netscape.javascript.JSObject.getWindow(this).call()</code>.</p>
  
  <p>But in order to register a JavaScript callback in the applet, I guess I would need an JavaScript function object of some sort.</p>
  
  <p>I would like to do:</p>
  
  <pre><code>public void registerCallback( SomeJavascriptFunction func ) { ... }
  </code></pre>
  
  <p>Which I could call from Javascript:</p>
  
  <pre><code>myapplet.registerCallback(function(){ alert("called back"); });
  </code></pre>
  
  <p>So I could call this function in later code:</p>
  
  <pre><code>func.call( ... );
  </code></pre>
  
  <p>Does something like this exist? How can I do this?</p>
  
  <p>Rigth now I'm thinking of creating some Javascript to handle this callback mechanism instead of doing so from the applet.</p>