Putting applets into a HTML, but how?
I wrote an applet which is called "IdrawApplet.java" and a HTML which is supposed to contain this applet. But somehow when I run the HTML it says that it can't find my java-Class. This is a "Dynamic-Web-Project". It has a "WebContent"-Folder which contains both, the HTML and the java-Class.
As you will see I tried to insert the applet in two different ways. By putting it in a "applet"-Tag and a "object"-Tag (as suggested) on SELFHTML.org:
<!-- <applet code= "IdrawApplet.class"
cod开发者_运维百科ebase= "../applets"
width= 320 height= 180></applet> -->
<object classid="java:IdrawApplet.class"
codebase="../applets"
width="800" height="600"></object>
Thanks in advance...
The proper way (which is also the HTML5 way) to embed a Java applet is:
<object type="application/x-java-applet" width="320" height="180">
<param name="code" value="MyJavaClass">
fallback content
</object>
However, IE doesn't support the standard way so you need to use IE conditional comments (in an HTML5-compatible way) like this:
<!--[if !IE]>-->
<object type="application/x-java-applet" width="320" height="180">
<param name="code" value="MyJavaClass">
fallback content
</object>
<!--<![endif]-->
<!--[if IE]>
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="320" height="180">
<param name="code" value="MyJavaClass">
fallback content
</object>
<![endif]-->
Note that for the value of the code param, it doesn't require the .class extension. Just the class name is preferable.
For IE, you can also specify a codebase attribute if you want to provide a location to a cab file where IE can fetch Java if you don't have it. However, if you want to specify the path to the directory the .class file is in, you do that (for any browser) with the codebase param.
As for enabling scripting with "mayscript", you shouldn't need to do that these days. But, if you need to for some reason, you do it with a mayscript param (not attribute) and set its value to true.
Note that the fallback content will only show when a handler for application/x-java-applet isn't present or is disabled. It won't show for a missing .class file as the Java plug-in still loads.
for that..first check your environment variables, then see the class file names, if you do not write .class extention than it may be works...and its batter to include applet file..like in header part of the html code
精彩评论