refresh iframe from inside itself with different domains

Dustin Silk picture Dustin Silk · Jun 25, 2013 · Viewed 12.2k times · Source

i have a webpage which is housing my iFrame which is from a different domain. Now i have a button inside the iFrame which when pressed, needs to refresh or reload the iframe.

I've tried a few methods which are blocked due to cross domain attempts..

Answer

Rob Hardy picture Rob Hardy · Jun 25, 2013

In your script within the iframe, try this:

document.location.href = document.location.href;

You can't access elements outside of your document model from within the iframe, including accessing the iframe itself. You can access the properties of the document within it however.