81,094
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript">
function imgSel(){
var img = new Image();//构造JS的Image对象
img.src = document.imageForm.file.value;//将本地图片赋给image对象
img.onreadystatechange=function(){
if (img.readyState=="complete"){
alert(["图片大小是:",img.width,img.height]);
document.imageForm.width.value = img.width;
document.imageForm.height.value = img.height;
document.imageForm.size.value = img.fileSize;
document.images['image'].src = img.src;
}
}
}
</script>
</head>
<body>
<form name="imageForm">
宽: <input name="width" type="text" size="6">
高: <input name="height" type="text" size="6">
大小: <input name="size" type="text" size="6"><br>
<input name="file" type="file" onChange="imgSel()"><br>
<img src="" name="image">
</form>
</body>
</html>