<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js get picture sizes and picture sizes (height and width) </title>
<script>
function Checkimg (IMG)
{
var message= "";
var maxwidth=1;//set Picture width limit
var maxheight=1;//set Picture height limit
if (img.readystate!= "complete") {
Return false;//ensure the picture is fully loaded
}
if (img.offsetheight>maxheight) message+= "Height excess:" +img.offsetheight;
if (img.offsetwidth>maxwidth) message+= "width excess:" +img.offsetwidth;
if (message!= "") alert (message);
}
</script>
<body>
<br> <input id=inp type= "file" onpropertychange= "Img1.src=this.value;" >
</body>
When the picture is loaded, you can get the picture size successfully, so you want to determine the size of the readystate== "complete"
Test Code Two
<script>
function Qford_getimagesize (filepath)
{
var imgsize={
width:0,
height:0
};
Image=new image ();
Image.src=filepath;
Imgsize.width =image. Width;
Imgsize. height=image. Height;
return imgsize;
}
</script>
JS get picture dimension function test:</br>
< Script type= "text/web Effects" ><!--
var a=qford_getimagesize ("Test.jpg");
Alert (' Width: ' +a.width + ' High: ' +a.height ';
</script>