Force iframe to Reload

$('iframe').attr('src', $('iframe').attr('src'));


  1. User Avatar
    Permalink to comment#

    I honestly only wanted to comment because your commenting system is gorgeous.


  2. User Avatar
    Permalink to comment#

    comment preview doesn’t has funcionality , AhahahhAHHAhh

  3. User Avatar
    Permalink to comment#


    How would you go about reloading 2 or more iFrames?

  4. User Avatar
    Permalink to comment#

    Thanks a lot !

  5. User Avatar
    Permalink to comment#

    Thank you very much. I’ve tried more than one way of doing this, but none really worked for me. This is the real deal! Thanks once again :)

  6. User Avatar
    Permalink to comment#

    $(‘iframe’).attr(‘src’,’Your src here ‘);

  7. User Avatar
    Permalink to comment#

    From Your text to link here…
    $( '#iframe' ).attr( 'src', function () { return $( this )[0].src; } );

  8. User Avatar
    Dheeraj Kawatra

    This code doesn’t work in case you have multiple iframes on a page. It replaces the url of all iframes to first one to be reloaded. More robust code jquery code would be:

      $('iframe').each(function (){
                   var src= $(this).attr('src');
                    $(this).attr('src', src);

  9. User Avatar
    Permalink to comment#

    If you want to reload all the frames inside te page you can try this

    document.querySelectorAll("iframe").forEach(function(e){ e.src+=""; });


    $("iframe").each(function(i,e){ e.src+=""; });

    well in both cases, it doesn’t solve the cache problem :/

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.