2

Possible Duplicate:
Javascript callback when IFRAME is finished loading?

Is there any way to wait until an iframe has fully loaded before removing a div?

I'm using the following:

  $("#myButton").click(function(event){
        $('#response').html("<img src='images/ajax-loader.gif' border=0> Please Wait - Loading!");
        $("#myIFrame").attr('src', $('#url').val());
  });

I'd like to remove the loading gif once the iFrame fully loads.

Any ideas?!

Thanks!!!

Community
  • 1
  • 1
Simon
  • 1,149
  • 6
  • 16
  • 32

1 Answers1

3

You can simply use the load event on your iframe:

 $("#myButton").click(function(event){
        $('#response').html("<span id='loader'><img src='images/ajax-loader.gif' border=0> Please Wait - Loading!</span>");
        $("#myIFrame").attr('src', $('#url').val());
  });

  $('#myIFrame').load(function(){
    $("#loader").remove();
  });
marcgg
  • 65,020
  • 52
  • 178
  • 231