-1

Have nice holidays! I will also have a nice New Year if I solve the problem. So I have an iframe, which is dynamically inserted in a certain place between page content. I need to reload the iframe on window resize, but I can't select it. I've tried:

$(window).on('resize', 'iframe', function(){
    //code for reloading
});

But it doesn't work. Any ideas?

Adam Azad
  • 11,171
  • 5
  • 29
  • 70

1 Answers1

2

This will not reload:

$(window).on('resize', 'iframe', function () {
    // reload the iframe window.
    this.contentWindow.location.reload();
});

But this does:

$(window).on('resize', function () {
  // reload the iframe window.
  $('iframe').each(function () {
    this.contentWindow.location.reload();
  });
});
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252