ok. i have to put this game in my html page as an applet...have all the class files, but not sure how make the game appear (in a separate window) after pressing the submit button on the html page. The following snippet is NOT what I want:

<a href="" target="_blank">
<p><input id="inputsubmit3" type="submit" name="inputsubmit3" value="Create Game" /></p></a>

Dani AI

Generated

Creating a small standalone HTML "launcher" that embeds your applet, then opening that page in a new window, is the simplest, most robust pattern. As suggested, opening a new window is the right idea; is correct that the opened window can be sized/controlled; and 's affirmation is fine. Avoid wrapping a submit input in an anchor or letting a form submit immediately — a form submission can navigate the current page before the new window shows. Two safe options: submit the form to a named target, or use a button that opens the launcher page.

Example: have your main page submit to a small launcher page called game.html (opens in a named window):

<form action="game.html" method="get" target="gameWindow">
  <input type="submit" value="Create Game">
</form>

Package your class files into one JAR (so browsers/plugins download one file):

jar cf checkers.jar *.class

Put the applet embed in game.html (launcher). This keeps the applet out of the main page and makes window sizing/controls straightforward for the opener:

<!DOCTYPE html>
<html>
  <body>
    <object type="application/x-java-applet" width="640" height="480">
      <param name="code" value="CheckersMain"/>
      <param name="archive" value="checkers.jar"/>
      Your browser does not support Java applets.
    </object>
  </body>
</html>

Cautions: modern browsers have dropped Java applet support — consider running in an old browser with the Java plugin or porting the game (for example, to HTML5 Canvas). Also remember pop-up blockers: open/target actions must be direct user gestures. For current-state details see the MDN note on the deprecated <applet> element and OpenJDK JEP 289; for a modern replacement path see the MDN Canvas tutorial.


JEP 289 — Deprecate the Applet API
MDN Canvas tutorial

Recommended Answers

All 3 Replies

Is this that, what you want ? :)

<input id="inputsubmit3" type="submit" name="inputsubmit3" value="Create Game" onclick="window.open('');" />

Also add the other parameters of the sub routine open()

<input id="inputsubmit3" type="submit" name="inputsubmit3" value="Create Game" onclick="window.open('');" />

Right solution.

For more help visit:
<URL snipped>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.