var image=new Image();   
image.src=src;
var srcW = image.width;
var srcH = image.height;
alert(srcW);

解决方案 »

  1.   

    实例化image 你的构造函数呢
      

  2.   

    因为网速问题。图片并不是一打好src就能加载的。请到图片的onload事件发生后再读width。
      

  3.   

    问题已解决
    感谢“为你心醉”
    http://hi.baidu.com/wishwingliao/blog/item/94559a2f139f7f391f3089a7.htmlvar image=new Image();   
    image.src=src;
    image.attachEvent("onreadystatechange",orsc);//当加载状态改变的时候执行orsc这个方法. function orsc(){
       if(img.readyState=="complete"){//当加载状态为完全结束时进入
           alert(image.width);
       }
    }
      

  4.   

    这样的确是取的不准比较保险的办法,IE使用onreadystatechange监听readyState为 loaded或complete时再获取
    其它浏览器可使用onload获取if(window.ActiveXObject) {
       img.onreadystatechange = function() {
          if(img.readyState == "loaded" || img.readyState == "complete") {
            img.onreadystatechange = null;
            alert(img.width);
         }
      }
    } else {
      img.onload = function() {
        img.onload  = null;
        alert(img.width);
       }
    }