Last active
August 29, 2015 14:26
-
-
Save gkralik/78da908b6b2a0cbb4356 to your computer and use it in GitHub Desktop.
Detect ClickOnce support of browser
This file contains hidden or 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
Detect if ClickOnce is (or rather: might be) supported by the browser. | |
This is partly based on https://gist.github.com/adunkman/2371101. | |
If the userAgent string does not contain a .NET feature hint, | |
we settle for everything that looks like an IE, because .NET | |
is installed nearly everywhere nowadays. | |
It might also be a good idea to check for the X-ClickOnceSupport | |
header on the server side. |
This file contains hidden or 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
(function () { | |
var isMimeSupported = function (desiredMime) { | |
var mimes = window.navigator.mimeTypes; | |
for (var i = 0; i < mimes.length; i++) { | |
if (mimes[i].type == desiredMime) { | |
return true; | |
} | |
} | |
return false; | |
}; | |
var isClickOnceSupported = function () { | |
var userAgent = window.navigator.userAgent.toLowerCase(), | |
hasDotNetFeatureHint = userAgent.indexOf('.NET CLR') >= 0, | |
looksLikeIE = userAgent.indexOf('msie') >= 0, | |
looksLikeTrident = userAgent.indexOf('trident') >= 0, | |
looksLikeEdge = userAgent.indexOf('edge') >= 0; | |
return hasDotNetFeatureHint || looksLikeIE | |
|| looksLikeTrident || looksLikeEdge | |
|| isMimeSupported('application/x-ms-application'); | |
}; | |
window.hasClickOnceSupport = isClickOnceSupported(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment