java plugin targeting through javascript

M

mark

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 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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top