zoukankan      html  css  js  c++  java
  • 微软官方的一段JavaScript判断.net环境

    <HTML> 
    <HEAD> 
    <TITLE>Test for the .NET Framework 3.5</TITLE> 
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" /> 
    <SCRIPT LANGUAGE="JavaScript"> 
    <!-- 
    var dotNETRuntimeVersion = "3.5.0.0"; 
    function window::onload() 
    { 
    if (HasRuntimeVersion(dotNETRuntimeVersion)) 
    { 
    result.innerText = 
    "This machine has the correct version of the .NET Framework 3.5." 
    } 
    else 
    { 
    result.innerText = 
    "This machine does not have the correct version of the .NET Framework 3.5." + 
    " The required version is v" + dotNETRuntimeVersion + "."; 
    } 
    result.innerText += "\n\nThis machine's userAgent string is: " + 
    navigator.userAgent + "."; 
    } 
    // 
    // Retrieve the version from the user agent string and 
    // compare with the specified version. 
    // 
    function HasRuntimeVersion(versionToCheck) 
    { 
    var userAgentString = 
    navigator.userAgent.match(/.NET CLR [0-9.]+/g); 
    if (userAgentString != null) 
    { 
    var i; 
    for (i = 0; i < userAgentString.length; ++i) 
    { 
    if (CompareVersions(GetVersion(versionToCheck), 
    GetVersion(userAgentString[i])) <= 0) 
    return true; 
    } 
    } 
    return false; 
    } 
    // 
    // Extract the numeric part of the version string. 
    // 
    function GetVersion(versionString) 
    { 
    var numericString = 
    versionString.match(/([0-9]+)\.([0-9]+)\.([0-9]+)/i); 
    return numericString.slice(1); 
    } 
    // 
    // Compare the 2 version strings by converting them to numeric format. 
    // 
    function CompareVersions(version1, version2) 
    { 
    for (i = 0; i < version1.length; ++i) 
    { 
    var number1 = new Number(version1[i]); 
    var number2 = new Number(version2[i]); 
    if (number1 < number2) 
    return -1; 
    if (number1 > number2) 
    return 1; 
    } 
    return 0; 
    } 
    --> 
    </SCRIPT> 
    </HEAD> 
    <BODY> 
    <div id="result" /> 
    </BODY> 
    </HTML>
    

      

  • 相关阅读:
    speechSynthesis 离线语音合成 浏览器自动播报
    提问的智慧
    实用工具
    《大数据时代》——思维导图
    数据分析技能提升十大建议
    vue根据权限生成动态路由及导航菜单
    vue中实现JavaScript桌面消息通知(push.js)
    vue中如何封装axios及如何使用
    启用多个服务器的webpack配置
    移动端input获取焦点弹出输入框时影响fixed布局的问题
  • 原文地址:https://www.cnblogs.com/malaohu/p/3214269.html
Copyright © 2011-2022 走看看