Search code examples
javascriptjqueryhtmlcross-domaincross-domain-policy

refresh iframe from inside itself with different domains


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


Solution

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