tags:

views:

17

answers:

1

Hi

javascript/jquery:

$(document).ready(function(){

$("a").click(function(e){

    var nr = $(this).attr("href").substr(2,3);
    var filename = "images/galerie/martina-flatau"+nr+".png";

    e.preventDefault();

    $('#mainview').fadeOut(function() {

        var image = $('<img />').attr('src', filename);       

        image.load(function(){                      
        $('#mainview').html(image).fadeIn();    
        });         

    });     

});

});

Question 1: Some pics (not all!) wont get loaded in Opera 9..I dont know why?

Question 2: Is there a way to improve the code (even the slightest bit?)

+1  A: 

Some pics (not all!) wont get loaded in Opera 9..I dont know why?

This is because you're setting the load event after specifying the src property. Some images will be loaded before the handler is defined.

Pekka
AHA - that works! thx :) ..what is a "handler"? is it the "image" var?
Don
@Don no, the function that fires on the `load` event.
Pekka