From 41405a53a03fed6386eec3ba18e61ec73320f2db Mon Sep 17 00:00:00 2001 From: zhaoqingqing Date: Fri, 19 Aug 2016 10:52:23 +0800 Subject: [PATCH] =?UTF-8?q?add=20Detect-DotNet-For-IE.js=20(ie=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E6=B5=8F=E8=A7=88=E5=99=A8=E6=A3=80=E6=B5=8B.net?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-w3c/Detect-DotNet-For-IE.html | 66 +++++++++++++++++++++++++++++++ web-w3c/Detect-DotNet-For-IE.js | 52 ++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 web-w3c/Detect-DotNet-For-IE.html create mode 100644 web-w3c/Detect-DotNet-For-IE.js diff --git a/web-w3c/Detect-DotNet-For-IE.html b/web-w3c/Detect-DotNet-For-IE.html new file mode 100644 index 0000000..f47416b --- /dev/null +++ b/web-w3c/Detect-DotNet-For-IE.html @@ -0,0 +1,66 @@ + + + + Test for the .NET Framework 3.5 + + + + + +
+ + + \ No newline at end of file diff --git a/web-w3c/Detect-DotNet-For-IE.js b/web-w3c/Detect-DotNet-For-IE.js new file mode 100644 index 0000000..1ff6700 --- /dev/null +++ b/web-w3c/Detect-DotNet-For-IE.js @@ -0,0 +1,52 @@ + //only for ie browser. chrome and firefox userAgent not contiant .net info so detech failed. + var dotNETRuntimeVersion = "3.5.0.0"; + window.onload = function() { + if (HasRuntimeVersion(dotNETRuntimeVersion)) { + //installed dotnet + result.innerText = "This machine has the correct version of the .NET Framework 3.5." + } else { + //not install dotnet + 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) { + if (versionString != null) { + 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(compareVer, sourceVer) { + if (compareVer == null || sourceVer == null) { + //console.log("CompareVersions version maybe null ,compareVer:" + compareVer + " ,userVer:" + sourceVer); + return 2; + } + for (i = 0; i < compareVer.length; ++i) { + var number1 = new Number(compareVer[i]); + var number2 = new Number(sourceVer[i]); + if (number1 < number2) + return -1; + if (number1 > number2) + return 1; + } + return 0; + } \ No newline at end of file