Reload an iframe with jQuery Reload an iframe with jQuery jquery jquery

Reload an iframe with jQuery


$( '#iframe' ).attr( 'src', function ( i, val ) { return val; });


If the iframe was not on a different domain, you could do something like this:

document.getElementById(FrameID).contentDocument.location.reload(true);

But since the iframe is on a different domain, you will be denied access to the iframe's contentDocument property by the same-origin policy.

But you can hackishly force the cross-domain iframe to reload if your code is running on the iframe's parent page, by setting it's src attribute to itself. Like this:

// hackishly force iframe to reloadvar iframe = document.getElementById(FrameId);iframe.src = iframe.src;

If you are trying to reload the iframe from another iframe, you are out of luck, that is not possible.


you can also use jquery. This is the same what Alex proposed just using JQuery:

 $('#currentElement').attr("src", $('#currentElement').attr("src"));