zoukankan      html  css  js  c++  java
  • 获取样式没有给固定高和宽的图片的高度和宽度

    方法一:

    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 : '+img.width+',height:'+img.height);    
    }else{    
        // 加载完成执行    
        img.onload = function(){    
            // 打印    
            alert('from:onload : '+img.width+',height:'+img.height);    
        };    
    }
    

      

      

  • 相关阅读:
    8.3学习日志
    8.2学习日志
    8.1学习日志
    Chapter 2
    未命名 1
    pugixml
    C++使用Json作为数据包装格式的通信
    项目FAQ
    xcode语法高亮插件
    【转】jsoncpp在xcode中的使用
  • 原文地址:https://www.cnblogs.com/dearxinli/p/2842858.html
Copyright © 2011-2022 走看看