Home > Web Front-end > JS Tutorial > Solution to CSS image caching problem under IE6_javascript skills

Solution to CSS image caching problem under IE6_javascript skills

WBOY
Release: 2016-05-16 18:14:24
Original
1399 people have browsed it

You can do it with one line of code:

Copy the code The code is as follows:

document.execCommand(" BackgroundImageCache", false, true);

Of course, in order for other browsers to pass normally, you need to make a judgment before calling, which is safer:

Copy code The code is as follows:

if(Browser.isIE6){
try{
document.execCommand("BackgroundImageCache ", false, true);
}
catch(e1){}
}


The platform detection code can be written like this, excerpted from the Ext source code:

Copy code The code is as follows:

var Browser = {};
try{
(function(){
var idSeed = 0,
ua = navigator.userAgent.toLowerCase(),
check = function(r){
return r.test(ua);
},
DOC = document,
isStrict = DOC.compatMode == "CSS1Compat",
isOpera = check(/opera/),
isChrome = check(/bchromeb/),
isWebKit = check(/webkit/),
isSafari = !isChrome && check(/safari/),
isSafari2 = isSafari && check(/applewebkit/4/), // unique to Safari 2
isSafari3 = isSafari && check(/version/3/),
isSafari4 = isSafari && check(/version/4/),
isIE = !isOpera && check(/msie/),
isIE7 = isIE && check(/msie 7/),
isIE8 = isIE && check(/msie 8/),
isIE6 = isIE && !isIE7 && !isIE8,
isGecko = !isWebKit && check(/gecko /),
isGecko2 = isGecko && check(/rv:1.8/),
isGecko3 = isGecko && check(/rv:1.9/),
isBorderBox = isIE && !isStrict,
isWindows = check(/windows|win32/),
isMac = check(/macintosh|mac os x/),
isAir = check(/adobeair/),
isLinux = check(/linux/),
isIpad = check(/ipad/),
isSecure = /^https/i.test(window.location.protocol);
extend(Browser,{
isOpera:isOpera,
isIE :isIE,
isIE6:isIE6,
isFirefox:isGecko,
isSafari:isSafari,
isChrome:isChrome,
isIpad:isIpad
});
})() ;
}catch(e){}


//The extend method above is also very easy

Copy Code The code is as follows:

function extend(obj1,obj2){
for(var o in obj2){
obj1[o] = obj2 [o];
}
return obj1;
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template