public
Last active

Detect ClickOnce support

  • Download Gist
README
1 2 3 4 5 6 7
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.
clickonce.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
(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();
 
})();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.