refresh iframe from inside itself with different domains [duplicate]
Asked Answered
G

1

5

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

Greedy answered 25/6, 2013 at 11:52 Comment(3)
What actually have you tried? Is the button calling JS code included within the iframe's document?Postage
window.location.reload() ?Dissolvent
I disagree that this question is a duplicate of #2065350 because this question is specifically about reloading from the document within the iframe, whereas that other question is about reloading from the parent document containing the iframe.Cloudland
H
14

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.

Hardman answered 25/6, 2013 at 12:13 Comment(2)
Worked for me on a similar problem where I had a form in the same domain in an iframe that wasn't reloading right in IE 11 and I had been working on it for over an hour when I saw this and I had a Eureka! moment (well, okay, it wasn't quite THAT dramatic, but it was a bright spot in an otherwise dull Monday at work)Hedonics
This worked for me reloading an iframe from inside the iframe.Koons

© 2022 - 2024 — McMap. All rights reserved.