2

Possible Duplicate:
Reload an iframe with jQuery

How can I cause an <iframe> to reload on a click event?

I tried this, but it is not working:

jQuery("#link").click(function(){
   jQuery('#iframeID')[0].reload();
})
Community
  • 1
  • 1
Krishna Kumar
  • 2,101
  • 1
  • 23
  • 34
  • 1
    This might already be the answer [iframe Jquery reload][1] [1]: http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery – zer02 Oct 02 '12 at 08:30

4 Answers4

7

like this

document.getElementById('iframeID').contentWindow.location.reload();

or via

document.getElementById('iframeID').src = document.getElementById('iframeID').src;
fedmich
  • 5,343
  • 3
  • 37
  • 52
2
    $("#reload").click(function() {
        jQuery.each($("iframe"), function() {
            $(this).attr({
                src: $(this).attr("src")
            });
        });
        return false;
    });

This above code will reload every iframe in your page, every time the link with id=reload is clicked

Thanks to @Haim Evgi

Or you can do the same also like this

$('iframe').each(function() {
  this.contentWindow.location.reload(true);
});
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
  • Thanks for this, very helpful to append a 'reload' class to all my modals with videos within and this handles them all perfectly. – JMarsh Nov 30 '16 at 02:21
1

You can do something like this:

$("#iframe").attr('src', ($('#iframe').attr('src'));
Mathlight
  • 6,436
  • 17
  • 62
  • 107
1
var iframe = document.getElementById('ID');

iframe.src = iframe.src;
Anton
  • 32,245
  • 5
  • 44
  • 54