将 applet 放入 HTML,但是如何呢?

发布于 2024-10-31 21:24:40 字数 531 浏览 3 评论 0原文

我编写了一个名为“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

度的依靠╰つ 2024-11-07 21:24:40

嵌入 Java 小程序的正确方法(也是 HTML5 方法)是:

<object type="application/x-java-applet" width="320" height="180">
    <param name="code" value="MyJavaClass">
    fallback content
</object>

但是,IE 不支持标准方法,因此您需要使用 IE 条件注释(以 HTML5 兼容的方式),如下所示:

<!--[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]-->

请注意,对于代码参数的值,它不需要 .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:

<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.

木有鱼丸 2024-11-07 21:24:40

为此..首先检查您的环境变量,然后查看类文件名,如果您不写.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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文