我有一个函数,检查图像加载是否正常。当我在函数中使用alert时,它会返回true,但是当我在函数后面使用时,它始终是错误的。我该如何解决这个问题?函数变量不传递到外部
var isInstalled = false;
function checkimg(){
isInstalled = true;
}
alert(isInstalled);
。
<img id="fire" src="player.png" onload="javascript: checkimg()" \>
如何根据预期查看变量isInstalled的变化? – user3304007
在结尾处是一种情况,另一种情况是,您可以创建超时。 setTimeOut(checkIsInstall,1000); – VinhNT
函数checkIsInstall(){ if(isInstalled){ setTimeOut(checkIsInstall,1000); (“Loaded”);其他{ } else { alert(“Loaded”); } } – VinhNT