What you can do in Internet Explorer is load an applet into the page which exposes methods that do the things you want to do. You get a reference to the applet, then invoke methods on that reference.
<applet id="myAppletId" name="myAppletName" ...>
var applet = document.getElementById('myAppletId');
var d = applet.getDateFromApplet();
In your applet you'd need a public method getDateFromApplet()
that returns a java.util.Date
.
Note that what I present should work, but it has been years since I did this (it worked in NS4, 6 and IE 4+ at the time). I didn't use getElementById()
however, I used var applet = document.myAppletName;
.
The other complication to this is that if you want this to execute on page load, the applet will almost certainly not be ready, which requires code something like:
function checkApplets() {
var da = document.applets; // document.getElementsByName('applet');?
if (da.length > 0) {
for (var ii = da.length; ii-- > 0;) {
if (!da[ii].isActive()) {
window.timerId = setTimeout(checkApplets, 250);
return;
}
}
if (window.timerId) {
clearTimeout(window.timerId);
}
}
window.appletsLoaded = true;
}
Lastly, it might (should) be possible to do this with the <object>
tag, but as I said, it has been years since I needed to interact with a Java applet in this way from client-side JavaScript, so I haven't tested it.