728x90 AdSpace

Latest News
Wednesday, April 5, 2017

What's the best way to reload / refresh an iframe using JavaScript?

Solution 1:

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

be careful, in Firefox, window.frames[] cannot be indexed by id, but by name or index.

Solution 2:

document.getElementById('iframeid').src = document.getElementById('iframeid').src;

It will reload the iframe, even across domains! Tested with IE7/8, Firefox and Chrome.

Solution 3:
If using jQuery, this seems to work:

$('#your_iframe').attr('src', $('#your_iframe').attr('src'));
  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Item Reviewed: What's the best way to reload / refresh an iframe using JavaScript? Rating: 5 Reviewed By: Thiruvikraman Govindarajan