[学习点滴]XP中JVM的判断方法

XP系统
1.在html里面声明自定义tag名称MSIE
<html xmlns:MSIE>
2.加入该段代码
<STYLE>
@media all {
   MSIE\:CLIENTCAPS {behavior:url(#default#clientcaps)}
}
</STYLE>
3.页面上设置控件
<MSIE:CLIENTCAPS ID="oClientCaps" />
4.判断是否有JVM
oClientCaps.isComponentInstalled("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","componentid")
返回值为boolean值
其中{08B0E5C0-4FCB-11CF-AAA5-00401C608500}为注册表中:
HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components
javavm控件的固定字符串(文件夹名)
5.判断jvm是否可用:
oClientCaps.JavaEnabled

MSDN上的例子(http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/xmlns.asp?frame=true):
<HTML XMLNS:MSIE>
<HEAD>
<STYLE>
@media all {
   MSIE\:clientCaps {behavior:url(#default#clientcaps);}
}
</STYLE>

<SCRIPT>
function window.onload()
{
   var bDataBindingAvailable  = false;
   var sDataBindingVersion = '';
   var sDataBindingID =
       "{333C7BC4-460F-11D0-BC04-0080C7055A83}";
   bDataBindingAvailable =
       oClientCaps.isComponentInstalled(sDataBindingID,"clsid");

   // if data binding is unavailable, install it
   if (!bDataBindingAvailable)
   {
      oClientCaps.addComponentRequest (sDataBindingID,
          "componentid");
      bDataBindingAvailable = oClientCaps.doComponentRequest();
   }
}
</SCRIPT>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
   <MSIE:CLIENTCAPS ID="oClientCaps" />
</BODY>


二,另外一种比上面简单的方式
1.在body里定义该控件(如下):
<BODY  STYLE="behavior:url(#default#clientCaps)" ID="oClientCaps">
2.判断是否有JVM
oClientCaps.isComponentInstalled("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","componentid")
3.判断jvm是否可用:
oClientCaps.JavaEnabled
MSDN上的例子(http://msdn.microsoft.com/workshop/author/behaviors/reference/behaviors/clientcaps.asp):
<SCRIPT>
function window.onload()
{
    var sVersion = oClientCaps.getComponentVersion ("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid");
myText.innerHTML = "<FONT SIZE=4>You are running Internet Explorer " + sVersion + ".</FONT>";
}
</SCRIPT>

<BODY BGCOLOR="#FFFFFF" STYLE="behavior:url(#default#clientCaps)" ID="oClientCaps">
<DIV ID="myText"></DIV>

注意点:在win7+IE9上如果用innerHTML赋值方式把behavior:url(#default#clientCaps)元素塞到DOM节点里面去的话,IE9下会判断java状态为false,即使你装了Java 插件。但是在develop tool上面选IE8 document Mode,这个状态检查就对了。 

你可能感兴趣的:(jvm,html,Microsoft,XP,asp)