gpt4 book ai didi

javascript - 在 Firefox 中,图像不显示。但在IE下却可以正常工作

转载 作者:行者123 更新时间:2023-11-28 02:01:04 26 4
gpt4 key购买 nike

fileuplad progress

在 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);

...


}

...
}

最佳答案

在哪里/如何处理图像的 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;

关于javascript - 在 Firefox 中,图像不显示。但在IE下却可以正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18441800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com