简体   繁体   中英

What is the best way of embedding a java applet into my webpage?

I've been looking into putting a little Java application in my web page, but the more research I do, the more confused I become about how I should do it. Sun suggests many ways of doing it, but it looks suspiciously like it's from the Netscape era.

So, should I use <applet> , as suggested by eclipse, <embed> , or <object> ?

And how should I use the correct tag?

Since Java 6 Update 10 they've released a Java Deployment Kit :

The Java Deployment Toolkit makes deploying Java applets or Java Web Start programs a snap. The Deployment Toolkit JavaScript file provides:

 * Accurate detection of installed JREs * Seamless JRE installation * Complete applet launching (JRE detection and, if necessary, upgrading) in a single line of code * Complete Web Start program launching in a single line of code 

The following HTML code is all it takes to ensure that Java 1.6 is installed and then a Java applet is launched:

<script src="http://java.com/js/deployJava.js"></script>

<script>
  deployJava.runApplet({codebase:"http://www.example.com/applets/",
     archive:"ExampleApplet.jar", code:"Main.class",
     width:"320", Height:"400"}, null, "1.6");
</script>

好吧,如果您想严格遵循标准,那么在这里快速浏览一下W3C标准就会指出applet已贬值,您应该使用object。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM