alert(gimg.width); 貌似图片大小预先定义了 才能读的到.......

解决方案 »

  1.   

    <!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=utf-8" />
    <title>无标题文档</title>
    <script language="javascript">
    var gimg = new Image(); function img()
    {
    var source = document.getElementById("inputImg").value; 
    gimg.src = source; 
    //alert(gimg.width);
    setTimeout("alert(gimg.width)",10);
    }</script>
    </head><body>
    <input type="file" id="inputImg"  name="inputImg" onchange="javascript:img()"/>
    </body>
    </html>
      

  2.   

    songpengasp朋友的方法我试了下,还是不行啊,打印出来的 width 的值还是为 0!