if (screen.width > 1439) { function getimagewidth(url,callback){ var img = new image(); img.src = url; // 如果图片被缓存,则直接返回缓存数据 if(img.complete){ callback(img.width, img.height); }else{ // 完全加载完毕的事件 img.onload = function(){ callback(img.width, img.height); } } } var culture_containboximgs = $('.culture_containbox').find('img'); culture_containboximgs.each(function(){ var imgw = $(this).attr('width'); var imgsrc = $(this).attr("src"); var _this = $(this); if(imgw == undefined){ getimagewidth(imgsrc,function(w,h){ _this.css('width',w); }); }else{ _this.css('width',imgw); } }); var case_detail_contentimg = $('.case_detail_content').find('img'); case_detail_contentimg.each(function(){ var imgw = $(this).attr('width'); var imgsrc = $(this).attr("src"); var _this = $(this); if(imgw == undefined){ getimagewidth(imgsrc,function(w,h){ _this.css('width',w); }); }else{ _this.css('width',imgw); } }); var productdetail_content = $('.productdetail_content').find('img'); productdetail_content.each(function(){ var imgw = $(this).attr('width'); var imgsrc = $(this).attr("src"); var _this = $(this); if(imgw == undefined){ getimagewidth(imgsrc,function(w,h){ _this.css('width',w); }); }else{ _this.css('width',imgw); } }); }