JavaScript & IE7 - Why won't my *.onload = function() { } fire?

I have a gallery I quickly coded up for a small site, and under Firefox 3 and Safari 3 works fine. But when I test on my old best friend IE7, it seems to not fire the imageVar.onload = function() { // code here }.. which I want to use to stop the load effect and load the image.

Please bear in mind...

  • I know the thumbnails are just scaled down version of the larger images. When the images are finalised by the client I am going to create proper thumbnails.
  • This is my first attempt to try and get out of procedural JavaScript for the most part.. so please go easy and kindly let me know where my code sucks!

Answers


For successful use of Image.onload, you must register the event handler method before the src attribute is set.

Related Information in this Question:

Javascript callback for Image Loading


Need Your Help

add a div at the end of wp_nav_menu function in wordpress

php html wordpress function menu

I want to add a div at the bottom of the wordpress wp_nav_menu so it will look like this:

Why does my font-face text look so bold?

css fonts font-face webfonts typography

Here is an image from the Photoshop design of the webpage:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.