我正在创建一个jQuery插件.
如何在Safari中使用Javascript获得真实的图像宽度和高度?
以下适用于Firefox 3,IE7和Opera 9:
var pic = $("img")
// need to remove these in of case img-element has set width and height
pic.removeAttr("width");
pic.removeAttr("height");
var pic_real_width = pic.width();
var pic_real_height = pic.height();
Run Code Online (Sandbox Code Playgroud)
但在像Safari和Google Chrome这样的Webkit浏览器中,值为0.