• 检测客户端是否安装 Silverlight 插件和判断IE是否安装或支持Silverlight(限IE)


    1、检测客户端是否安装 Silverlight 插件
    <script type="text/javascript">  
    function CheckSilverlightInstalled()  
    {  
    var isSilverlightInstalled = false;   
    try{  
    try{  
    var slControl = new ActiveXObject('AgControl.AgControl'); //检查IE  
    isSilverlightInstalled = true;   
    }  
    catch(e){   
    if(navigator.plugins["Silverlight Plug-In"]) //检查非IE  
    {  
    isSilverlightInstalled = true;   
    }  
    }  
    }  
    catch(e){}  
    return isSilverlightInstalled;   
    }  
    alert("是否安装了 Silverlight 插件?" + CheckSilverlightInstalled())  
    </script> 
    <script type="text/javascript">
    function CheckSilverlightInstalled()
    {
    var isSilverlightInstalled = false;
    try{
    try{
    var slControl = new ActiveXObject('AgControl.AgControl'); //检查IE
    isSilverlightInstalled = true;
    }
    catch(e){
    if(navigator.plugins["Silverlight Plug-In"]) //检查非IE
    {
    isSilverlightInstalled = true;
    }
    }
    }
    catch(e){}
    return isSilverlightInstalled;
    }
    alert("是否安装了 Silverlight 插件?" + CheckSilverlightInstalled())
    </script>

    2、JS判断IE是否安装或支持Silverlight!(只能检测IE)

    JS判断IE是否安装或支持Silverlight!
    JS中可以使用try,catch语名判断客户端是否安装了Silverlight插件,使用插件的IsVersionSupported方法判断目前客户端是否支持指定版本的Silverlight程序!
    view plaincopy to clipboardprint?
    <mce:script language="javascript"><!--  
    function validSilverlight(d)   
    {   
        var c=false,a=null;   
        try   
        {   
            var b=null;   
    var v=window.navigator.userAgent;   
    if(v.indexOf("MSIE")>-1)   
    {   
    b=new ActiveXObject("AgControl.AgControl");   
    }   
    else if(navigator.plugins["Silverlight Plug-In"])   
    {   
      a=document.createElement("div");   
      document.body.appendChild(a);   
      if(v.indexOf("Safari")>-1)   
          a.innerHTML='<embed type="application/x-silverlight" />';   
              else a.innerHTML='<object type="application/x-silverlight"  data="data:," />';   
              b=a.childNodes[0]   
            }   
            //document.body.innerHTML;   
            if(b.IsVersionSupported(d))c=true;   
            b=null;   
        }catch(e)   
        {   
          c=false   
        }   
        if(a)document.body.removeChild(a);   
        return c;   
    }   
    alert(validSilverlight("1.0"));   
    // --></mce:script>  
    <mce:script language="javascript"><!--
    function validSilverlight(d)
    {
        var c=false,a=null;
        try
        {
            var b=null;
    var v=window.navigator.userAgent;
    if(v.indexOf("MSIE")>-1)
    {
    b=new ActiveXObject("AgControl.AgControl");
    }
    else if(navigator.plugins["Silverlight Plug-In"])
    {
      a=document.createElement("div");
      document.body.appendChild(a);
      if(v.indexOf("Safari")>-1)
          a.innerHTML='<embed type="application/x-silverlight" />';
              else a.innerHTML='<object type="application/x-silverlight"  data="data:," />';
              b=a.childNodes[0]
            }
            //document.body.innerHTML;
            if(b.IsVersionSupported(d))c=true;
            b=null;
        }catch(e)
        {
          c=false
        }
        if(a)document.body.removeChild(a);
        return c;
    }
    alert(validSilverlight("1.0"));
    // --></mce:script>
    由于ASP.NET 中的 Silverlight控件使用了这种检测,所以如果您使用了此控件就可以直接使用方法“Silverlight.isInstalled(version)”调用了!

  • 相关阅读:
    在intent-filter中的配置
    利用asynchttpclient开源项目来把数据提交给服务器
    URL的应用
    ScrollView在布局中的作用
    android中传统的创建数据库
    for (Sms sms : smsLists){}
    Android中对文件的读写进行操作
    android中的5大布局
    android复制包需要修改的几个地方
    【Unity Tips】备忘录(扫盲篇)
  • 原文地址:https://www.cnblogs.com/dotfun/p/1644430.html
Copyright © 2020-2023  润新知