将 APPLET 标签转换为 IE6 的 OBJECT 标签

发布于 2024-08-14 05:23:16 字数 1473 浏览 3 评论 0原文

我已将以下小程序标签转换为对象标签,以便它可以工作。但由于某种原因,下面的内容不起作用。首先,下面的转换正确吗?

Applet:

document.writeln('<applet'); 
document.writeln('  code="LittleShootApplet"');
document.writeln('  id="LittleShootApplet" name="LittleShootApplet"');
document.writeln('  scriptable="true"');
document.writeln('  mayscript="true"');     
document.writeln('  height="0" width="0"');
document.writeln('  style="xdisplay: none; width:0; height:0; padding:0; margin:0;" >');
document.writeln('</applet>');

对象:

document.writeln('<OBJECT ');
document.writeln('classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" height="0">');     
document.writeln('<PARAM name="code" value="LittleShootApplet">');
document.writeln('<PARAM name="id" value="LittleShootApplet">');
document.writeln('<PARAM name="scriptable" value="true">');
document.writeln('<PARAM name="mayscript" value="true">');
document.writeln('<PARAM name="style" value="xdisplay: none; width:0; height:0; padding:0; margin:0;">');
document.writeln('</OBJECT>');

顺便说一句,我正在使用 JavaScript 将以上内容写入页面。

我在页面上有一个按钮,尝试使用 JavaScript 调用 Java Applet 函数,但出现此错误。

Message: 'document.LittleShootApplet' is null or not an object
Line: 77
Char: 1
Code: 0
URI: http://localhost/webs/front-end/activity.php

上述 Javascript 在从 Java 小程序调用函数时遇到问题,因为小程序尚未正确加载。

感谢大家的帮助。

I have converted the following applet tags to object tags so that it can work. But for some reason the below isn't working. Firstly, Is the below a correct conversion that should work?

Applet:

document.writeln('<applet'); 
document.writeln('  code="LittleShootApplet"');
document.writeln('  id="LittleShootApplet" name="LittleShootApplet"');
document.writeln('  scriptable="true"');
document.writeln('  mayscript="true"');     
document.writeln('  height="0" width="0"');
document.writeln('  style="xdisplay: none; width:0; height:0; padding:0; margin:0;" >');
document.writeln('</applet>');

Object:

document.writeln('<OBJECT ');
document.writeln('classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" height="0">');     
document.writeln('<PARAM name="code" value="LittleShootApplet">');
document.writeln('<PARAM name="id" value="LittleShootApplet">');
document.writeln('<PARAM name="scriptable" value="true">');
document.writeln('<PARAM name="mayscript" value="true">');
document.writeln('<PARAM name="style" value="xdisplay: none; width:0; height:0; padding:0; margin:0;">');
document.writeln('</OBJECT>');

Btw, I am using JavaScript to write the above to the page.

I have a button on the page which tries to call a Java Applet function using JavaScript but I get this error.

Message: 'document.LittleShootApplet' is null or not an object
Line: 77
Char: 1
Code: 0
URI: http://localhost/webs/front-end/activity.php

The above Javascript is having trouble calling functions from the Java applet because the applet hasn't been loaded properly.

Thanks all for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

凌乱心跳 2024-08-21 05:23:16

IDName 属性直接添加到 object 标记,而不是作为 param 的:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" 
 id="LittleShootApplet" name="LittleShootApplet">
...
</OBJECT>

已删除document.write 以提高可读性。

我建议您通过 ID 获取元素,而不是通过 document.elementName

 var applet = document.getElementById('LittleShootApplet');
 // instead of document.LittleShootApplet

Add the ID and Name attributes directly to the object tag, not as param's:

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="0" 
 id="LittleShootApplet" name="LittleShootApplet">
...
</OBJECT>

Removed document.write for readability.

And I would recommend you to get the elements by ID, not by document.elementName:

 var applet = document.getElementById('LittleShootApplet');
 // instead of document.LittleShootApplet
南七夏 2024-08-21 05:23:16

Firefox 因您的 classid 属性而失败。下面的内容应该可以跨浏览器工作: -

<object type="application/x-java-applet"
 name="LittleShootApplet" width="0" height="0">
    <param name="code" value="LittleShootApplet">
    <param name="scriptable" value="true">
    <param name="mayscript" value="true">
</object>

在我的测试中,IE8 和 FF5 都需要“type”属性,您省略了该属性。仅 1.6.0.10 之前的 Java 插件需要 mayscript 参数。根据 javadocs 1.6.0.21,仍然需要可编写脚本的参数。在使用 1.6.0.24 对签名小程序进行的测试中,IE8 从 JS 调用它为 OK,而无需将 scriptable 设置为 true。

Firefox fails with your classid attribute. The below should work cross browser:-

<object type="application/x-java-applet"
 name="LittleShootApplet" width="0" height="0">
    <param name="code" value="LittleShootApplet">
    <param name="scriptable" value="true">
    <param name="mayscript" value="true">
</object>

In my tests both IE8 and FF5 required the "type" attribute, which you omitted. The mayscript param is only required for Java plugins before 1.6.0.10. The scriptable param is still required according to javadocs 1.6.0.21. In a test with 1.6.0.24 for a signed applet, IE8 called it OK from JS without scriptable being set true.

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