这是由于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();
你有没有尝试把JavaScript放入window.onload事件? – NibblyPig 2010-06-08 08:40:13
@SLC它不属于那里 – Midhat 2010-06-08 08:58:41