本地判断图片大小和宽度是可以的;IE6下测试通过,其他还没考虑JS兼容性

来源:互联网 发布:淘宝ipad版不能横屏 编辑:程序博客网 时间:2024/06/05 16:37

本地判断图片大小和宽度是可以的;IE6下测试通过,其他还没考虑JS兼容性!

JScript code
<html><head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <script>function test(){ var img2=document.getElementById('img1');alert('图片大小为'+parseInt(img2.fileSize/1024)+'K');//大小,你测试看看!} </script></head><body><img src="1.jpg" id="img1"/><input type="button" onclick="test();" value="测试"/></body></html>
原创粉丝点击