Force iframe to Reload

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

Comments

  1. User Avatar
    Alex
    Permalink to comment#

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

    Kudos

  2. User Avatar
    junior
    Permalink to comment#

    comment preview doesn’t has funcionality , AhahahhAHHAhh

  3. User Avatar
    Celine
    Permalink to comment#

    Thanks!!

    How would you go about reloading 2 or more iFrames?

  4. User Avatar
    Laurent
    Permalink to comment#

    Thanks a lot !

  5. User Avatar
    Nenad
    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
    esm
    Permalink to comment#

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

  7. User Avatar
    Codeplussoft
    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);
                });
    
    

Submit 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.

icon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag