jquery wait until iframe is loaded

iframe, jquery, load

Solution

Why not use jQuery.load function which has a callback for managing displayed text:

HTML

<button id="myLoadButton">Load</button>
<div id="Myiframe"></div>

JS

$('#myLoadButton').click(function(){
   $(this).text('Please wait...');
   $('#Myiframe').load('ajax/test.html', function(){
      $('#myLoadButton').text('Content loaded!');
   });
})

Problem

Hello, I'm using a button in order to change the src of an iframe when I click it this way: ``` $("#iframe").attr('src',"someurl"); ``` Is there any way to display a "Please wait" message or a gif loader until the new URL is loaded?

Original source

Related problems