Home  >  Article  >  Web Front-end  >  Background image caching under ie6_HTML/Xhtml_web page production

Background image caching under ie6_HTML/Xhtml_web page production

WBOY
WBOYOriginal
2016-05-16 16:41:191444browse

Bug in CSS background image flickering under IE6 (background image caching issue under IE6)

The background image under IE6 will resend the request every time it is used (non-local). Even with a hover effect, the same background image is only in a different position, and IE6 will send the request again. This frustrating thing needs to be solved:
For IE, filter:expression is very powerful and can implement a lot of functions. However, for programmers who regard efficiency as their life, its efficiency is not flattering, so some people will use CSS methods to achieve it. Background image caching under IE6, but this kind of people just admire the power of Microsoft:

Copy the code
The code is as follows:

html {filter:expression(document.execCommand("BackgroundImageCache", false, true));} Of course, the disadvantage: it may slow down the loading speed of the entire page

Most people will choose the js method to implement:

Copy the code
The code is as follows:



Disadvantages: If An error will occur when executing under browsers such as Firefox.

So you need to determine whether it is an IE browser. The determination method provided by jQuery is as follows:

Copy the code
Code As follows:



A simpler way is to use IE’s conditional comments:

Copy the code
The code is as follows:


Statement:
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