"mark" <z5h@hotmail.com> wrote in message
news:fe341124.0309040501.3f233640@posting.google.c om...
| Adding an applet to a web page through the <object> tag, allows you to
| target the JVM in 2 ways.
|
| (ref.
http://java.sun.com/products/plugin/versions.html )
|
| 1. "Dynamic Versioning", which basically means "run with version X or
| greater".
| 2. "Static Versioning", which targets a very specific version, e.g.
| 1.3.1_06.
|
| Sadly, the reality for developers is neither. Usually an application
| is developed/tested for a specific range of versions, e.g. 1.3.1_02 ->
| 1.3.1_07.
I thought you could get the JVM version from the various browser's object
models. I know you can use VBScript in IE to create Java objects of a
specific version and have seen scripts that iterate until they hit one that
returns an object. Not sure how to do it in JS though.
|
| I thought I might be able to use some JavaScript trick to iterate
| through a few "Static Versioned" values, and stop when a successful
| applet initialization took place.
|
| I don't really do much JavaScripting so I have been unsuccessful. Any
| help is appreceated. Here is an example first attempt (minus
| irrelevent stuff) so you know I'm not completely lazy:
|
|
| <html>
| <head>
| <title>Plugin Target Test</title>
| <script type="text/javascript">
|
|
|
| function tryV(version)
| {
| document.write('trying ' + version + '<br>');
|
| for (i=0; i<version; i++) //has an earlier version worked?
| {
|
| if(document.getElementById("version" + i)!=null) // NOTE: this
| doesn't really do what I want, but the idea is there
| return;
| }
|
|
|
|
| //classid value targets Java 1.3.1_0[version]
| document.write('<OBJECT id="version' + version + '" classid =
| "clsid:CAFEEFAC-0013-0001-000' + version + '-ABCDEFFEDCBA" ');
| //document.write(' codebase =
|
"http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#
Version=1,4,2,0"
| ');
| document.write(' WIDTH = 100% HEIGHT = 100% NAME = "Applet"
| ALIGN = center > ');
| document.write(' <PARAM NAME = CODE VALUE = "com.foo.Bar" > ');
| document.write(' <PARAM NAME = ARCHIVE VALUE = " ');
| document.write(' jar1.jar, jar2.jar" ');
| document.write(' <PARAM NAME = NAME VALUE = "Applet" > ');
| document.write(' <PARAM NAME = "type" VALUE =
| "application/x-java-applet;jpi-version=1.3"> ');
| document.write(' <PARAM NAME = "scriptable" VALUE = "false"> ');
| document.write(' <PARAM NAME = "PROPERTIES"
| VALUE="applet.properties"> ');
| document.write(version + 'no good<br> ');
| document.write(' </OBJECT>');
|
| }
|
| </script>
| </head>
| <body>
|
| <!--"CONVERTED_APPLET"-->
| <!-- HTML CONVERTER -->
| <script type="text/javascript">
|
| //try some acceptable values
| tryV(3);
| tryV(4);
| tryV(5);
| tryV(6);
|
| </script>
| </body>
| </html>