Http://photo.163.com/shixiaojian089/train/28002 This is NetEase's an album, see after want to try to do look.
In my production method, you need to get the width of each photo, so it's natural to use the JQ width () method. It's not a big problem to run under FF and IE, but on Chrome, there's a problem.
Using alert troubleshooting, we found that the chrome width method takes a value of 0. In this case, the picture is not loaded at all when the script is running here. The problem should be in $ (function () {}), because this method only requires the DOM to run when it finishes loading. Then change into the onload under the implementation, sure enough this can be. But this is obviously not a very good way, after all, in the onload run to wait until the entire contents of the whole file loaded and then run the script.
Online search After, found that this brother Mody Http://www.jb51.net/article/50402.htm also encountered the same problem, under its comments there is a solution, you can refer to:
In the place where you want to get the picture wide and high
Copy Code code as follows:
$img. Load (function () {
var img_h = $img. Height ();
var img_w = $img. Width ();
}
This can still use the $ (function () {}), call the Load method on the picture object where the picture is loaded, and avoid waiting for the entire contents of the file to be loaded.