IE6 background image no-Cache solution and image Usage Policy multiple methods summary _ javascript skills

Source: Internet
Author: User
The recently discovered Web project in IE6 has the problem that background images are not cached. I searched the internet and found that it is already a well-known BUG. Here I will summarize various solutions. solution 1: IE6 Hack script

The Code is as follows:


Script
If (navigator. appName = "Microsoft Internet Explorer "){
Var B _version = navigator. appVersion;
Var version = B _version.split (";");
Var trim_Version = version [1]. replace (/[]/g ,"");
If (trim_Version = "MSIE6.0 "){
; // Alert ("Internet Explorer 6.0 ");
Try {
Document.exe cCommand ("BackgroundImageCache", false, fix );
} Catch (err ){}
}
}
Script


Solution 2: IE6 Hack comment

The Code is as follows:


Script


Solution 3: IE6 Hack Style

The Code is as follows:


Html {}
{
Filter: expression(document.exe cCommand ("BackgroundImageCache", false, true ));
}


But the above method can not solve the problem of using images in innerHTML without caching, the problem of Microsoft official explanation reference: http://support.microsoft.com/default.aspx? Scid = kb; en-us; 319546

To solve the problem of background image caching, you can use CSS background-image for definition and cache for only one access. For IMG tags, some websites use a GIF image of 1 pixel (both width and height) as the SRC value, indicating that the content is defined by style classes, for example:

The Code is as follows:


. Yahoo
{
Background: url ('img/yahoo.png ') no-repeat;
Width: 16px;
Height: 16px;
}



When using images in Web applications, you need to consider the number of image requests, image size, and image definition.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.