将 applet 放入 HTML,但是如何呢?
我编写了一个名为“IdrawApplet.java”的小程序和一个应该包含该小程序的 HTML。但不知何故,当我运行 HTML 时,它说找不到我的 java 类。 这是一个“动态网络项目”。它有一个“WebContent”文件夹,其中包含 HTML 和 java 类。
正如您将看到的,我尝试以两种不同的方式插入小程序。通过将其放入 SELFHTML.org 上的“小程序”标签和“对象”标签(按照建议):
<!-- <applet code= "IdrawApplet.class"
codebase= "../applets"
width= 320 height= 180></applet> -->
<object classid="java:IdrawApplet.class"
codebase="../applets"
width="800" height="600"></object>
提前致谢...
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"
codebase= "../applets"
width= 320 height= 180></applet> -->
<object classid="java:IdrawApplet.class"
codebase="../applets"
width="800" height="600"></object>
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嵌入 Java 小程序的正确方法(也是 HTML5 方法)是:
但是,IE 不支持标准方法,因此您需要使用 IE 条件注释(以 HTML5 兼容的方式),如下所示:
请注意,对于代码参数的值,它不需要 .class 扩展名。最好只提供类名。
对于 IE,如果您想要提供 cab 文件的位置,IE 可以在其中获取 Java(如果您没有),则还可以指定代码库属性。但是,如果您想指定 .class 文件所在目录的路径,则可以使用代码库 param 来执行此操作(对于任何浏览器)。
至于使用“mayscript”启用脚本,现在您不需要这样做。但是,如果您出于某种原因需要这样做,您可以使用 mayscript 参数(而不是属性)来执行此操作,并将其值设置为 true。
请注意,仅当 application/x-java-applet 的处理程序不存在或被禁用时,后备内容才会显示。由于 Java 插件仍在加载,因此不会显示缺少的 .class 文件。
The proper way (which is also the HTML5 way) to embed a Java applet is:
However, IE doesn't support the standard way so you need to use IE conditional comments (in an HTML5-compatible way) like this:
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.
为此..首先检查您的环境变量,然后查看类文件名,如果您不写.class扩展名,那么它可能会起作用...并且它的面糊包括小程序文件..就像
在html代码的标题部分
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