<input type="button" value="GET Size" onclick="getFileSize(document.getElementById('xx'))" /> <img src="a.jpg" id="xx" alt="" /> <script> function getFileSize(o) { x = window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("MSxml2.XMLHTTP"); x.open("HEAD", o.src, false); x.send(); alert("大小:" + x.getResponseHeader("Content-Length")); } </script>