2013-08-26 38 views
1

fileuplad progress,圖片沒有顯示。但在IE瀏覽器,它的工作原理

在IE中,我的代碼顯示3張圖像(最小化,還原,關閉)在右側和窗口的頂部。但在Firefox和Chrome中,它失敗了。

如何更正?

謝謝。

function Panel(_caption,_width,_height,_confirmFunction) { 
     this.icon=new Array(); 
     this.icon["minimize"]=Env.envPath+'/UI/images/minimize.gif'; 

        ... 

     this.init=function() { 
      this.mainDiv=document.createElement("div"); 
      this.mainDiv.style.cssText="padding:2px 2px 2px 2px;position:absolute;width:"+_width+"px;left:50%;margin-left:-"+(_width/2)+"px;top:50%;margin-top:-"+(_height/2+50)+"px;border-right:1px solid gray;border-top: 1px solid white;border-left:1px solid white;border-bottom:1px solid gray;background-color:#F2F1ED"; 
      document.body.appendChild(this.mainDiv); 
      this.mainDiv.handler=this; 

      this.toolDiv=document.createElement("div"); 
      this.toolDiv.style.cssText="background-color:#47649A;height:20px;float:right;margin-left:-3px"; 
      this.mainDiv.appendChild(this.toolDiv); 
      var _img=document.createElement("img"); 
      _img.src=this.icon["minimize"]; 
      _img.style.cssText="margin-top:2px;cursor:pointer"; 
      _img.title="Minimize"; 
      _img.handler=this; 
      _img.onclick=function(event) { 
       this.handler.minimize(); 
      } 
      this.toolDiv.appendChild(_img); 

      ...    


     }   

     ... 
    } 
+1

什麼'Env.envPath'爲不同的瀏覽器的價值? –

+3

如果您將代碼的HTML輸出(可能位於jsfiddle中)以便其他人修改/調試輸出,可能會有所幫助。 – Warty

回答

1

哪裏/你如何處理圖像的onload事件?
您應該在使用之前預先加載所有圖片。

萬一有幫助,有我在一個簡單的方式預加載如何處理:

var toLoadCount = 1; // at least we have to load window. 

// do the same for each image you want to load 
toLoadCount++; 
var myImage=newImage(); 
myImage.onload = oneLoaded ; 
myImage.src = ... some src... 
// 

function oneLoaded { 
    toLoadCount--; 
    if (!toLoadCount) allLoaded() 
} 

function allLoaded() { 
    // here is the function that really starts your page 
} 

window.onload = oneLoaded; 
相關問題