// Using deployJava.runApplet to target specific element // from http://stackoverflow.com/questions/13517790/using-deployjava-runapplet-to-target-specific-element?answertab=active#answer-15139480 function writeTo(func, node) { var content = ""; var oldwrite = document.write; document.write = function(add) { content += add; }; func(); document.write = oldwrite; node.innerHTML += content; } function launchApplet() { var attributes = { //code : "esieequest.Main", //archive : "/game/esieequest.jar" code : "java2d.Java2DemoApplet.class", archive : "http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/examples/dist/depltoolkit_Java2Demo/Java2Demo.jar" }; var parameters = { permissions : "sandbox" }; var version = "1.7"; deployJava.runApplet(attributes, parameters, version); } function launchGame() { var wrapper = document.getElementById("play"); if (deployJava.versionCheck("1.7+")) { writeTo(launchApplet, wrapper); } else { wrapper.innerHTML = '

Java ≥7 is required to run this game.
Click here to get the latest Java Runtime Environment.

'; } } // Run the applet only when the user wants to play // https://developer.mozilla.org/en-US/docs/Web/API/window.onhashchange var launched = false; function locationHashChanged() { if (location.hash === "#play" && !launched) { launched = true; launchGame(); } } window.onhashchange = locationHashChanged; locationHashChanged();