Calling Applet With JavaScript

Hello,

I’ve been trying to work on a javascript function to call this applet:

<applet code="MyClass.class"
   codebase="http://www.mysitehere.com/applet"
   archive="applet_en.zip" width="600" height="425"
   alt="lounge" MAYSCRIPT>
   <param name="room" value="232289">

</applet>

The reason I’m trying to get this to work is because I’d like to be able to allow my visitors the ability to call the JS function from their web page like so:


<script type="text/javascript"
  src="http://www.mysitehere.com/JS_include/applet_code.js">
</script>

and have that applet automatically run seamless.

No matter how I try to write the JS function, I cannot get this to work.

How do I go about writing this function so it works properly?

I’ve searched the forums and web searched but could not find anything that remotely touched on this.

Thanks for your help.

putting


var script = '<applet code="MyClass.class" codebase="http://www.mysitehere.com/applet" archive="applet_en.zip" width="600" height="425" alt="lounge" MAYSCRIPT><param name="room" value="232289"></applet>';
document.write(script);

In the javascript file should do it?

hi gRoberts and thank you for your help.

I tried your suggestion and placed that bit of code into an external JS file named applet.js like so:


var script = '<applet code="MyClass.class"
 codebase="http://www.mysitehere.com/applet"
archive="applet_en.zip" width="600" height="425" alt="lounge" MAYSCRIPT>
<param name="room" value="232289"></applet>';
document.write(script);

and placed the call calling the applet.js file into a normal html page but I still cannot get it to work.

The error I received was:

line: 2
char: 42
error: unterminated string constant
code: 0

Inspecting the code, I cannot find the error it is referring to.

Thanks again

the code has to be on one line, like I have in my example. Your example spans it across multiple lines which causes the compiler to think everything after


var script = '<applet code="MyClass.class"

is a new line/variable.

Man alive I feel retarded lmao. For the life of me I couldn’t figure out what I was doing wrong. That’s what I get for trying to pretty up the code lol.

Thanks alot gRoberts, works like a charm!

You should never feel like that… it happens to the best of us.

I’m glad your getting there…