Possible duplicates:get the height and width of the image in the javascript text tag.Determining image file size + sizes through Javascript?How to load preview image before loading via JavaScript
how can i get the height and width of the image without refreshing the page in the file tag?
<HTML> <HEAD> <TITLE></TITLE> <script language="javascript"> function getW() { var theImg = document.getElementById('testimg'); alert(theImg.width); } function getH() { var theImg = document.getElementById('testimg'); alert(theImg.height); } </script> </HEAD> <BODY> <input type="file" id="testimg"/> <input type="button" value="get Width" onclick="getW()"/> <input type="button" value="get Height" onclick="getH()"/> </BODY> </HTML>
I get the height and width of the image using php code, but this temporary page will be updated, without refreshing the page I get the image size, but not the height and width ....
Use the event onload:
onload
document.getElementById('testimg').onload = function() { alert(document.getElementById('testimg').offsetHeight); }
, , .
, , Javascript , .
- .
- , ( ), - ajax-, ( ) img.width img.height.
img.width
img.height
, .