diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index db12e792a2..611ea839a8 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -390,6 +390,12 @@ OpenLayers.Util.onImageLoadError = function() { this.style.display = ""; }; +/** + * Property: alphaHackNeeded + * {Boolean} true if the png alpha hack is necessary and possible, false otherwise. + */ +OpenLayers.Util.alphaHackNeeded = null; + /** * Function: alphaHack * Checks whether it's necessary (and possible) to use the png alpha @@ -397,25 +403,27 @@ OpenLayers.Util.onImageLoadError = function() { * Explorer. * * Returns: - * {Boolean} true if alpha has is necessary and possible, false otherwise. + * {Boolean} true if the png alpha hack is necessary and possible, false otherwise. */ OpenLayers.Util.alphaHack = function() { - var arVersion = navigator.appVersion.split("MSIE"); - var version = parseFloat(arVersion[1]); - var filter = false; + if (OpenLayers.Util.alphaHackNeeded == null) { + var arVersion = navigator.appVersion.split("MSIE"); + var version = parseFloat(arVersion[1]); + var filter = false; - // IEs4Lin dies when trying to access document.body.filters, because - // the property is there, but requires a DLL that can't be provided. This - // means that we need to wrap this in a try/catch so that this can - // continue. + // IEs4Lin dies when trying to access document.body.filters, because + // the property is there, but requires a DLL that can't be provided. This + // means that we need to wrap this in a try/catch so that this can + // continue. - try { - filter = !!(document.body.filters); - } catch (e) { - } + try { + filter = !!(document.body.filters); + } catch (e) {} - return ( filter && - (version >= 5.5) && (version < 7) ); + OpenLayers.Util.alphaHackNeeded = (filter && + (version >= 5.5) && (version < 7)); + } + return OpenLayers.Util.alphaHackNeeded; }; /**