这是因为 IE6 中的所有内容都在同一个线程中执行——甚至是 gif 动画。
确保在开始之前显示 gif 的唯一方法是分离执行。
function longRunningProcess(){
....
hideGif();
}
displayGif();
window.setTimeout(longRunningProcess, 0);
但这仍然会使浏览器在longRunningProcess
执行时冻结。
为了允许交互,您必须将代码分成更小的片段,也许像这样
var process = {
steps: [
function(){
// step 1
// display gif
},
function(){
// step 2
},
function(){
// step 3
},
function(){
// step 4
// hide gif
}
],
index: 0,
nextStep: function(){
this.steps[this.index++]();
if (this.index != this.steps.length) {
var me = this;
window.setTimeout(function(){
me.nextStep();
}, 0);
}
}
};
process.nextStep();