IE Image caching Document.execcommand ("Backgroundimagecache", false,true) _javascript tips

Source: Internet
Author: User
Tags set background
The Pixy method is blinking because of the cache bug impact of IE. In fact, it is not clear about this problem, but in fact the bug is conditional, ie cache set to every visit to the page, rather than the default automatically. Basically, only developers will be able to set the cache for each access check update, so this bug does not affect the real user (according to the WINXPSP2 IE6 test, although may still call a network access API, but there is no actual request, The symptom is that the mouse has a very short time jitter, but the image does not flicker. In addition, an undisclosed method was found to allow IE to cache the background image: Document.execcommand ("Backgroundimagecache", False,true)
This method even avoids the API call, seemingly is directly cached in IE memory.

IE6 Set background picture is not really cache live, even if the server did cache, if you want to cache live only ~ ~ ~

People who have done UI design and development must know that IE (excluding IE7) will often reload the background image from the server side, and that the UI interface is being tossed around IE (excluding IE7).

Erik found a simple solution (for IE that works under IE7, which actually fixes the bug in IE7).

Program code
Copy Code code as follows:

Document.execcommand ("Backgroundimagecache", false, true);

Read the source of Ext today to find that Jack Slocum has taken this into account, in Ext.js gave his implementation, in other AJAX frameworks should not have such a similar code, from this one detail can see ext Comprehensive ~

Program code
Copy Code code as follows:

var Isie = Ua.indexof ("MSIE") >-1, isIE7 = Ua.indexof ("MSIE 7") >-1;
Remove CSS Image flicker
if (Isie &&!isie7) {
try{
Document.execcommand ("Backgroundimagecache", false, true);
}catch (e) {}
}

Today, reading the Dreamplayer player source code found that the Phantom is also for IE's background cache for the repair, but he did not consider that there is no IE7 in this phenomenon, this is a piece of related code in Evml.js ~ (by the way muttered two: This guy, write JS never add a semicolon, It used to be like this, now or so, so how to compress ah, Khan ~ The following code according to my habits have been added semicolon, even if only two or three words ~)

Program code
Copy Code code as follows:

Window.isie=navigator.appname.indexof ("Microsoft") ==0;
if (Isie) {
Document.documentElement.addBehavior ("#default #userdata");
Document.execcommand ("Backgroundimagecache", false,true);
}

A while back a lot of people where covering I to work around the bug that IE always
Reloads background images from the server and leading to your UI flickering.
Dean wrote one and lots of the others wrote the same thing. Today, I saw the simple workaround
(from a fellow Googler who worked at Microsoft before):

Document.execcommand ("Backgroundimagecache", false, True)

Much simpler but makes me wonder why this isn't the default setting?

/**
* Related reply
* by Nicholas C. Zakas @2007-02-26
*/
I ' ve actually wondered about this ' bugs ' for a while.
I ' m sure somewhere along the line this decision is made for a logical reason ...
Maybe they didn ' t anticipate how much background images the would be used, or maybe they
There is some use case under which it would is desirable not to cache the background image.
I ' m generally not the overriding things that seem to is design decisions (which this seems to be).
I ' ve never really thought this is a "bug" ... bugs don ' t usually have the switches that say "Turn off bug".

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.