Reputation: 563
In IE, My code shows 3 images (minimize, restore, close) in the right and top of window. But in Firefox and Chrome, it fails.
how to correct?
Thanks.
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);
...
}
...
}
Upvotes: 1
Views: 114
Reputation: 19294
where/how do you handle the onload event of the images ?
You should pre-load all pictures before using them.
In case it helps, there's how i handle in a simple way preloading :
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;
Upvotes: 1