欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

获取图片宽、高

程序员文章站 2022-06-21 14:49:35
...
var image = new Image();
            var that = this;
            image.onload = function(){
                if ("naturalWidth" in image) { // 现代浏览器
                    that.width = image.naturalWidth;
                    that.height = image.naturalHeight;
                } else { // IE6/7/8
                    that.width = image.width;
                    that.height = image.height;
                }
                image = undefined;
                delete image;
            }



转载于:https://my.oschina.net/u/232595/blog/469156