Ancient Temple City

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'));
Labels:
Reactions:

Post a Comment

[blogger]

MKRdezign

{facebook#http://www.facebook.com/GTVCreations} {twitter#http://www.twitter.com/GTVCreations} {google-plus#http://www.google.com} {pinterest#http://www.pinterest.com} {youtube#http://www.youtube.com} {instagram#http://www.instagram.com}

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget