本文介绍了图像预加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请,有人可以告诉我为什么警报在下一页中显示为未定义
Hi,
Please, could someone tell me why the alert shows undefined in the following page
<html>
<head>
<title>test</title>
<script language="JavaScript">
var theLargeImg;
function loadImage(url)
{
theLargeImg = new Image();
theLargeImg.onload=imageLoaded();
theLargeImg.src = url;
}
function imageLoaded()
{
alert("img height="+theLargeImg.Height+";img width="+theLargeImg.Width+";complete = "+theLargeImg.complete+&"; src= "+theLargeImg.src);
}
</script>
</head>
<body>
<input type="button" onclick="javascript:loadImage('http://www.google.co.uk/intl/en_ALL/images/logos/images_logo_lg.gif')" value="Load Image">
</body>
</html>
谢谢,
理查德.
Thanks,
Richard.
推荐答案
function loadImage(url)
{
theLargeImg = new Image();
theLargeImg.src = url;
theLargeImg.onload=imageLoaded();
}
2."Height"和"Width",首字母均应为小写.
2. "Height" and "Width" ,both first letter should be low-case.
这篇关于图像预加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!