I have a javascript function that gets called after a successful jQuery AJAX call.
function launchTool(user, pass, name, hash, port)
{
var iframe = jQuery('<iframe id="AppletFrame" src="http://www.mysite.com/applications/applet.html"></iframe>');
var $dialog = jQuery('<div></div>');
$dialog.append(iframe);
$dialog.dialog({
title: name,
width: '425',
height: '400',
modal: true,
close: function () {
iframe.attr("src", "");
}
});
}
This opens up a java applet that is in an iframe which is shown in a jQuery dialog. This works great but now I need to pass in values to the java applet. This post looks exactly what I need.
So I tried this:
function launchTool(user, pass, name, hash, port)
{
var iframe = jQuery('<iframe id="AppletFrame" src="about:blank"></iframe>');
var doc = document.getElementById('AppletFrame').contentWindow.document;
doc.open();
doc.write('<script>');
doc.write('var attributes = {code:"com.test.MyApplet", width:400, height:375};');
doc.write('var parameters = {jnlp_href: "http://'+window.location.host+'/applications/MyConfigApplet.jnlp", user: "'+user+'", pass: "'+pass+'", name: "'+name+'", hash: "'+hash+'", port: "'+port+'"};');
doc.write('</script>');
doc.write('deployJava.runApplet(attributes, parameters, "1.6");');
doc.close();
var $dialog = jQuery('<div></div>');
$dialog.append(iframe);
$dialog.dialog({
title: name,
width: '425',
height: '400',
modal: true,
close: function () {
iframe.attr("src", "");
}
});
}
Basically I've tried to add contents of the applet.html
in my working example to the code. I see no errors and the only thing that comes up is an empty iframe. I guess this doesn't actually apply to the src attribute. What am I doing wrong?
EDIT: As suggested by @TheZuck I added deployJava.js with:
doc.write('<script src="https://www.java.com/js/deployJava.js"></script>')
Now at least I get an error: TypeError: document.getElementById(...) is null
Why?