方法一:
var img =new Image();
img.src = e(w.body).find('img').attr('src');//e(w.body).find('img')是要设置的图片
var imgWidth=img.width;
var imgHeight=img.height;
var width=window['xheditor-img'].getAttribute('width')||imgWidth,
height=window['xheditor-img'].getAttribute('height')||imgHeight
方法二:
// 图片地址
var img_url = '/static/upload/2013/13643608813441.jpg';
// 创建对象
var img = new Image();
// 改变图片的src
img.src = img_url;
// 判断是否有缓存
if(img.complete){
// 打印
alert('from:complete : width:'+img.width+',height:'+img.height);
}else{
// 加载完成执行
img.onload = function(){
// 打印
alert('from:onload : width:'+img.width+',height:'+img.height);
};
}
浙公网安备 33010602011771号