Created
April 12, 2012 21:28
-
-
Save adunkman/2371101 to your computer and use it in GitHub Desktop.
Detect ClickOnce support
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
This detects the presence of ClickOnce in IE, Chrome (with extension), and | |
Firefox (with extension). | |
It doesn't work if Firefox is using Microsoft's .NET Framework Assistant when | |
adding .NET information to the User Agent string is turned off (the default | |
setting as of late). I personally worked around this by using server logic to | |
detect if the X-ClickOnceSupport header was set. |
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 () { | |
// Detect if ClickOnce is supported by the browser. | |
// Roughly based on http://stackoverflow.com/a/4653175/117402 | |
var hasMimeSupport = function (desiredMime) { | |
var mimes = window.navigator.mimeTypes, | |
hasSupport = false; | |
for (var i = 0; i < mimes.length; i++) { | |
var mime = mimes[i]; | |
if (mime.type == desiredMime) { | |
hasSupport = true; | |
} | |
} | |
return hasSupport; | |
}; | |
var sniffForClickOnce = function () { | |
var userAgent = window.navigator.userAgent.toUpperCase(), | |
hasNativeDotNet = userAgent.indexOf('.NET CLR 3.5') >= 0; | |
return hasNativeDotNet || hasMimeSupport("application/x-ms-application"); | |
}; | |
window.clickOnce = sniffForClickOnce(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment