Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Detect-DotNet-For-IE.js (ie内核浏览器检测.net版本信息)
- Loading branch information
1 parent
9075e88
commit 41405a5
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<HTML> | ||
|
||
<HEAD> | ||
<TITLE>Test for the .NET Framework 3.5</TITLE> | ||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" /> | ||
<script type="text/javascript"> | ||
//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; | ||
} | ||
</script> | ||
</HEAD> | ||
|
||
<BODY> | ||
<div id="result" /> | ||
</BODY> | ||
|
||
</HTML> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |