views:

269

answers:

1

Hello all,

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.

+1  A: 

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
CMS
Thanks for the reply, I made those changes but it still hasn't managed to load up the applet in IE6. I will have to open a more specific question. Thanks.
Abs