Mickey Segal said on 15/03/2006 4:34 AM AEST:[color=blue]
> The long-simmering Eolas patent dispute:
>
http://www.microsoft.com/presspass/p...06EOLASPR.mspx
> has led to an optional Microsoft Update:
>
http://support.microsoft.com/kb/912945/en-us
> that creates non-JavaScript problems that can be fixed using JavaScript.
>
> With the Microsoft update installed, Java applets (as well as other content
> such as Flash videos) are unable to receive user input until an activating
> click or key press. Although this update has not been installed by many
> users yet, is expected to be included in a periodic security update, making
> it very widespread, possibly as early as today.
>
> For Java applets there is a satisfactory workaround using JavaScript as
> detailed at:
>
www.segal.org/java/HelloPatent/
> However, since Java experts are not JavaScript experts, it was not clear
> whether our code was written in the best way. Specifically, we'd appreciate
> input as to whether we need both of the following lines of JavaScript code
> or can get rid of the HEAD part and make a call that includes the file name
> to invoke the function. The relevant JavaScript code is:
>
> Between the HEAD tags:
> <script src="specifyApplet.js" language="JavaScript"[/color]
The language attribute is deprecated so ditch it, keep type.
[color=blue]
> type="text/javascript"></script>
>
> Where I actually insert the applet:
> <script
> language="JavaScript"type="text/javascript">getAppletTags();</script>[/color]
If you mean can you do:
<script src="specifyApplet.js" type="text/javascript">
getAppletTags();
</script>
the answer is no. Wherever an src attribute is specified then:
"If the src has a URI value, user agents must ignore the
element's contents and retrieve the script via the URI."
<URL:http://www.w3.org/TR/html4/interact/scripts.html#edef-SCRIPT>
So I guess strictly speaking you can do it but it won't work in most
(nearly all) browsers. There was a recent thread on this but I can't
find it right now.
However, the element that loads the script doesn't have to be in the
head. The script element that loads the .js file must be before any
script element that calls code in the file, so it may be more convenient
to use (wrapping allowed deliberately):
<script src="specifyApplet.js" type="text/javascript"></script><script
type="text/javascript">getAppletTags();</script>
You may want to supply an argument to getAppletTags() and you only need
the first script element once in the document (before the first call to
getAppetTags()), it doesn't have to be added for every call.
--
Rob