Jquery 如何在ie6和chrome里获取一张图片的宽度跟高度
Jquery 怎么在ie6和chrome里获取一张图片的宽度跟高度?
谢谢!
------解决方案--------------------
var theImage = new Image();
var iurl = $("#eee").attr("src");
var fk = 0,fg = 0;
theImage.onload=function(){
fk = this.width;
fg = this.height;
alert(fk+" "+fg);
};
theImage.src = iurl;
------解决方案--------------------
(document).ready(function(){
var img = $('#eee');
if(img[0].width){
$("#aaa").html(img[0].width);
}else{
img[0].onload = function(){
$("#aaa").html(img[0].width);
}
}
});
------解决方案--------------------
------解决方案--------------------
谢谢!
<div id="aaa"></div>
<div id="ccc" style="display:none;"><img src="http://www.csdn.net/css/logo.png" id="eee" /></div>
<script language="javascript">
$(document).ready(function(){
var theImage = new Image();
var iurl = $("#eee").attr("src");
var fk = 0,fg = 0;
theImage.src = iurl;
$("#aaa").load(iurl,function(){
fk = theImage.width;
fg = theImage.height;
if(fk == 0){
fk = 500;
fg = 300;
};
};
$("#aaa").html(fk);
});
</script>
------解决方案--------------------
var theImage = new Image();
var iurl = $("#eee").attr("src");
var fk = 0,fg = 0;
theImage.onload=function(){
fk = this.width;
fg = this.height;
alert(fk+" "+fg);
};
theImage.src = iurl;
------解决方案--------------------
(document).ready(function(){
var img = $('#eee');
if(img[0].width){
$("#aaa").html(img[0].width);
}else{
img[0].onload = function(){
$("#aaa").html(img[0].width);
}
}
});
------解决方案--------------------
var screenImage = $(this).find('img');
theImage.src = screenImage.attr("src");
var imageWidth = theImage.width;
var imageHeight = theImage.height;
------解决方案--------------------
$(document).ready(function () {
var theImg = new Image();
theImg.src = $("#aaa").attr("src");
var ss = $("#aaa").attr("height");
alert(theImg.width+"=="+theImg.height);
});