Question

My task is using hidden signed applet which support cryptography functions. Applet has to be loaded dynamically.

I try to use this example: (no links, just open first google search result from Oracle website) "invoking Applet Methods From JavaScript". The problem is when the applet is loaded and deployed with "deployJava.js" ZK window is disappearing.

My code is:

 function loadScript(url, callback)
 {
      // Adding the script tag to the head as suggested before
      var head = document.getElementsByTagName('head')[0];
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = url;

      // Then bind the event to the callback function.
      // There are several events for cross browser compatibility.
      script.onreadystatechange = callback;
      script.onload = callback;

      // Fire the loading
      head.appendChild(script);
      callback();
 }

 function startApplet() {
      var invokeApplet = function () {
      var attributes = { id:'cryptoApplet', code:'CryptoApplet',  width:1, height:1} ;
      var parameters = { jar: 'clientcrypto.jar'} ;
      deployJava.runApplet(attributes, parameters, '1.7');
      };
      loadScript("/js/deployJava.js", invokeApplet);
 }
Était-ce utile?

La solution

This problem happens because deployJava.js use "document.write(applet tag)" to add an applet. I add div component to the page which has width="1", height="1", and rewrite deployJava.js to append applet in that div. And it's worked.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top