Skip to content

Instantly share code, notes, and snippets.

Created April 14, 2012 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2384288 to your computer and use it in GitHub Desktop.
Save anonymous/2384288 to your computer and use it in GitHub Desktop.
HTML Image Load Events Test
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(window).load(function() {
console.log("Window Load: " + $("img").width() + "x" + $("img").height());
});
$(document).ready(function() {
console.log("Document Ready: " + $("img").width() + "x" + $("img").height());
$("img").load(function() {
console.log("Image Load: " + $("img").width() + "x" + $("img").height());
});
});
</script>
</head>
<body>
<p><img src="http://i.imgur.com/B0Li3.jpg" alt="Heidi"></p>
</body>
</html>
<!--
Firefox 11.0:
Document Ready: 844x598
Image Load: 844x598
Window Load: 844x598
Chromium 18.0.1025.142 (Ontwikkelaarsbuild 129054 Linux) Ubuntu 11.10:
Document Ready: 0x0
Image Load: 844x598
Window Load: 844x598
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment