Back to index

wims  3.65+svn20090927
CheckVersion.java
Go to the documentation of this file.
00001 /*
00002     J.M. Evers
00003     A check for browserversion.
00004     A very small applet to be started before the WIMSchem applet.
00005     Example:
00006     
00007     <applet id="CheckApplet" name="CheckApplet" data="WIMSchem/CheckVersion.class" archive="dist/WIMSchem.jar" width="1" height="1">
00008     </applet>
00009     <script language="javascript" type="text/javascript">
00010        var VERSION_REQUIRED = 150;
00011        var javaVersion;
00012        try { javaVersion = document.getElementById("CheckApplet").getVersion(); alert(javaVersion);} catch(e){ javaVersion = 0;}
00013        if( javaVersion < VERSION_REQUIRED ){
00014            if(javaVersion==0){
00015               alert(" It seems your browser does not support Java - Javascript communication.\n Continue at own risk...");
00016            }
00017            else
00018            {            
00019               var t=confirm("You must go to the java download page to get the latest JavaPlugin...\nMinimal Version :"+VERSION_REQUIRED);
00020               if(t){window.open("http://java.sun.com/javase/downloads/index.jsp","","status=1,toolbar=1,width=600,height=480");}
00021            }
00022        }      
00023     </script>
00024 */
00025 
00026 package WIMSchem;
00027 import java.applet.*;
00028 
00029 public class CheckVersion extends Applet{
00030     public void init(){}
00031     public void stop(){}
00032     public void destroy(){}
00033     public String Version = System.getProperty("java.version");
00034 
00035     public String getVersion(){
00036        String[] v=Version.split("\\.");
00037        String version="";// 1.5.0_test123
00038        for(int p=0;p<v.length;p++){
00039            if(v[p].length() == 1 || v[p]!=null){
00040               version=version+""+v[p];
00041            }
00042        }
00043        if(version.length()!=3){
00044            if(version.length()==1){version=version+"00";}
00045            if(version.length()==2){version=version+"0";}
00046        }
00047        return version;
00048     }
00049 }
00050