This discussion is archived
5 Replies Latest reply: Sep 7, 2010 5:19 AM by 843802 RSS

Important addition to deployJava.js

843802 Newbie
Currently Being Moderated
Hello,

We slowly started to use deployJava.js on our produciton servers, and except few problems with Mac, it works pretty good. Today we needed dynamically (on a click), to populate a DIV with code like this, to start an applet.
<script>
    var attributes = {codebase:'http://java.sun.com/products/plugin/1.5.0/demos/jfc/Java2D',
                      code:'java2d.Java2DemoApplet.class',
                      archive:'Java2Demo.jar',
                      width:710, height:540} ;
    var parameters = {fontSize:16} ;
    var version = '1.6.0' ;
    deployJava.runApplet(attributes, parameters, version);
</script>
And the reason why we don't do it at page load, because we don't want to run an applet everytime somebody visits the page, only when they click on a button. So, the problem was, that deployJava.runApplet method, which calls writeAppletTag method uses document.write(), which completely destroys content of the page. So, we had to make a local copy of deployJava.js, and change document.write() to just return us a string, which then we populate using innterHTML, and applet worked like a charm.

So, since it's not a good idea to have a local copy of this deploy js tool, I would like to ask Sun to create a special method, which would return a HTML instead of using document.write directly.

Thank you in advance,

--Dmitri