li.的博客
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</HEAD>
<script language="javascript">
var img=null;
function chkimg(inp)
{
if(img)img.removeNode(true);
img=document.createElement("img");
img.attachEvent("onreadystatechange",isimg);
img.attachEvent("onerror",notimg);
img.src=inp;
}
function notimg()
{
alert("您插入的不是图片,请重新选择插入");
}
function isimg()
{
show.insertAdjacentElement("BeforeEnd",img);
show1.innerHTML = "图片大小"+ img.fileSize/1024+"K<br/>图片宽度"+img.offsetWidth+"<br/>图片高度"+img.offsetHeight;
}
</script>
<BODY>
<div id="show"></div>
<div id="show1"></div>
<input type="file" name="" onpropertychange="chkimg(this.value)"/>
</BODY>
</html>