日期:2014-05-16 浏览次数:20535 次
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
<style>
</style>
</head>
<body>
<p>
<img src="http://www.baidu.com/img/baidu_jgylogo3.gif" />
<input />
</p>
<p>
<img src="http://avatar.profile.csdn.net/2/3/6/2_missccc.jpg" />
<input />
</p>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
function $t(name, cot){
cot = cot || document;
return cot.getElementsByTagName(name);
}
var img = $t('img');
for(var i = 0, len = img.length; i < len; i++){
img[i].onload = function(){
$t('input', this.parentNode)[0].value = '图片高度: '+this.offsetHeight;
}
}
</script>
</body>
</html>