将 APPLET 标签转换为 IE6 的 OBJECT 标签
我已将以下小程序标签转换为对象标签,以便它可以工作。但由于某种原因,下面的内容不起作用。首先,下面的转换正确吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 ID 和 Name 属性直接添加到
object
标记,而不是作为param
的:已删除document.write 以提高可读性。
我建议您通过 ID 获取元素,而不是通过
document.elementName
:Add the ID and Name attributes directly to the
object
tag, not asparam
's:Removed document.write for readability.
And I would recommend you to get the elements by ID, not by
document.elementName
:Firefox 因您的 classid 属性而失败。下面的内容应该可以跨浏览器工作: -
在我的测试中,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:-
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.