Convert APPLET tags to OBJECT tags for IE6
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 obje开发者_JS百科ct
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.
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
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.
精彩评论