From 89ba3266292f9bfbdb72ce294d5376162d13d9ea Mon Sep 17 00:00:00 2001 From: Dan Gaidula Date: Thu, 20 Nov 2014 17:51:59 -0500 Subject: [PATCH] Fix for IE 10 no Flash crash on detect IE 10 with no Flash was crashing. Updated detection per Microsoft bulletin regarding ActiveXObject detection. Also tweaking isIE to be more compressible. http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx --- src/_.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/_.js b/src/_.js index b39876d..e4ec801 100644 --- a/src/_.js +++ b/src/_.js @@ -1,14 +1,24 @@ -var idCounter = 0; +var nav = navigator, plugins = nav.plugins, ua = nav.userAgent, idCounter = 0; var _ = { - hasFlash: ((typeof navigator.plugins != 'undefined' && - typeof navigator.plugins['Shockwave Flash'] == 'object') || - (window.ActiveXObject && (new ActiveXObject('ShockwaveFlash.ShockwaveFlash')) !== false)), + hasFlash: (function (){ + var a, hasFlash = false; + if(!!plugins && typeof plugins['Shockwave Flash'] == 'object') { + hasFlash = !hasFlash; + }else if ( !!window.ActiveXObject ) { + try { + a = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); + if(a){ + hasFlash = !hasFlash; + } + }catch(e){} + } + return hasFlash; + })(), - isIE: !!navigator.userAgent.match(/msie/i) || - !!navigator.userAgent.match(/Trident\/7\./), + isIE: !!ua.match(/msie/i) || !!ua.match(/Trident\/7\./), uniqueId: function(prefix) { var id = idCounter++;