document.ready不代表图片加载完毕,所以在document.ready里调用$(”img”).height()或者width()时,在强制刷新页面时很容易就获得错误的值。
解决办法1:
$(document).ready(function() {
// regular jQuery code
$(window).load(function() {
// use height() and width() on images here
});
});
来源于
http://forum.jquery.com/topic/jquery-height-and-width-returning-incorrect-values-in-opera
解决办法2:
$(document).ready(function() {
// regular jQuery code
$(”img”).load(function() {
// use height() and width() on images here
});
});
基于1的修改,有可能会出现如果img本地有缓存的话,貌似不会触发load事件,待确认。