What is the best way to reload (or) refresh an iframe using JavaScript?

Solution 1:

document.getElementById('iframeid').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:

$('#iframeid').attr('src', $('#iframeid').attr('src'));

Comments

Popular posts from this blog

About 12 Alwars

Post thumbnails from external URLs don’t appear in Blogger. How to resolve?

What is the unicode character for the close symbol?

ஸ்தல விசேஷம் - திருக்கோவிலூர் திவ்யதேசம்