How Can I Reload An Iframe Inside Iframe With JavaScript?
I have a domain, example.com Iframe's source is, server1.example1.com The problem is, I would like to refresh the iframe with JavaScript inside my iframe, when I location.reload
Solution 1:
perhaps try this:
// Reload the current page, without using the cache
document.location.reload(true);
source: https://developer.mozilla.org/en-US/docs/Web/API/Location.reload
I know Chrome does some pretty clever things with its cache, so maybe that will help.
Solution 2:
right click and reload frame, seriousle:
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 reload
var 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.
Post a Comment for "How Can I Reload An Iframe Inside Iframe With JavaScript?"