Modifying applet parameters in Client-side Javascript
Posted: Wed May 12, 2004 7:20 pm
I've had a rather frustrating problem today, which I was hoping to get some insight on. I have been working on a contract which involves a Java applet, some canned Shockwave, and a Javascript clock. Anyway, part of the goal is to have the applet randomly play a streaming image from a list; while the final version is going to be server-side (probably Javascript ASP, but this hasn't been settled yet), the current demo is being written entirely client-side, from a hardcoded list of examples. The examples are just the ID codes for the images, which are actually stored on a shared server. The IDs are passed to the applet as <PARAM>s. The code examples given for the applet use the deprecated <APPLET> tag, and since when I tried re-writing it with <OBJECT> it would not work under MSIE 6 (though it would under Mozilla 1.6 and Opera 7.3), I left it as it was.
My intention, when I went to code the demo around noon (PDT) today, was to simply write a function to select an ID, and then once I was sure I was getting them selected with reasonable pseudo-randomness (shown using a test page I set up), I then wrote a snippet of Javascript to generate a <PARAM> tag with the appropriate ID value. It went something like this:
However, this didn't work, and unfortunately, it didn't raise a Javascript console error, either; the applet would try to load, then crash.
When that didn't work, I pored over my Javascript and DHTML refs, and tried doing a few web searches, but came up empty. I spend the whole afternoon trying to find some way to set the parameter programatically, but everything I tried either failed the same way, or else turned out to be specific to the applet that a given web page was describing and thus not applicable. Eventually, out of frustration, I tried modifying the applet reference to use an <OBJECT> tag - and to my amazement, it worked (in Mozilla and Opera, anyway). However, since the primary target is IE, this may not be so useful; IE doesn't seem to recognize the tag at all, at least not with the applet in question.
Any suggestions? I'm at wits' end over this. Fortunately, the client is patient, but he will need this working before the 25th.
As a side note, I'm finally seeing some real activity with the freelance work, and I may soon have a long-term contract for some helldesk work - not my first choice of jobs, but since it's done on a telecommuting basis, and the hours are flexible, I am more than willing to do it, esp. after such a long period of unemployment. It also means that I can continue to work on the independent contracting, which is definitely a Good Thing in my not-so-humble opinion.
BTW, why does the forum software keep separating the name of the language into 'Java Script'? I mean, it even does it in the code blocks, which is potentially problematic.
My intention, when I went to code the demo around noon (PDT) today, was to simply write a function to select an ID, and then once I was sure I was getting them selected with reasonable pseudo-randomness (shown using a test page I set up), I then wrote a snippet of Javascript to generate a <PARAM> tag with the appropriate ID value. It went something like this:
Code: Select all
<applet name="foo" code="foo.class">
<param name="bar" value="whatever">
<!-- ... more params -->
<script language="Javascript1.2">
document.write('<param name="quux" value="' + GetId() + '" />');
</script>
<!-- still more params -->
</applet>
When that didn't work, I pored over my Javascript and DHTML refs, and tried doing a few web searches, but came up empty. I spend the whole afternoon trying to find some way to set the parameter programatically, but everything I tried either failed the same way, or else turned out to be specific to the applet that a given web page was describing and thus not applicable. Eventually, out of frustration, I tried modifying the applet reference to use an <OBJECT> tag - and to my amazement, it worked (in Mozilla and Opera, anyway). However, since the primary target is IE, this may not be so useful; IE doesn't seem to recognize the tag at all, at least not with the applet in question.
Any suggestions? I'm at wits' end over this. Fortunately, the client is patient, but he will need this working before the 25th.
As a side note, I'm finally seeing some real activity with the freelance work, and I may soon have a long-term contract for some helldesk work - not my first choice of jobs, but since it's done on a telecommuting basis, and the hours are flexible, I am more than willing to do it, esp. after such a long period of unemployment. It also means that I can continue to work on the independent contracting, which is definitely a Good Thing in my not-so-humble opinion.
BTW, why does the forum software keep separating the name of the language into 'Java Script'? I mean, it even does it in the code blocks, which is potentially problematic.