0

I have a JS function that is called in an iFrame that performs a post to my server and THEN is suppose to refresh the parent page of the iFrame. When I click a button on a third party site, a hidden div is rendered with my iframe. Once I make a submit post, I want to refresh the page (3rd party) page.

So the current setup for that website (which is third party and I have no control over their code), is this:

  • Body
  • div
  • div
  • div
  • table
  • tr
  • my iframe
  • ....

So the code that is attached to my jQuery ajax POST call is such:

    .....
    xhtml.append("}).done(function() { alert('im here'); window.location.reload(false);});");
    xhtml.append("}");
    .....

I'd prefer not showing all the code - but I can confirm that the done callback from the post IS called correctly AND the page does appear to "refresh" - but it should be treating it almost like I first entered the page, with my iframe closed.

How do I get almost a fresh reload of the page/css/etc? I figured this would work, but it appears it doesn't.

--Edit--

I realized that adding reload(true) will reload the server on initial request. However, the other content that renders (to view the hidden div) doesn't appear to reload correctly. It leaves the hidden divs up.

--Edit 2--

It looks like that window.location.reload(false); isn't a true "replica" of a browser refresh call. Which is ideally what I'm looking for.

user2124871
  • 803
  • 3
  • 9
  • 25

1 Answers1

0

Instead of saying window.location.reload

try using window.parent.location.reload

Above options will only work in case of the page and contents of IFrame both are hosted on same domain.

Vinod
  • 1,882
  • 2
  • 17
  • 27
  • Nothing happens: Permission denied to access property 'reload' – user2124871 Aug 19 '13 at 21:34
  • Looks like the contents of iframe are from a different domain. In that case you will get permission denied. – Vinod Aug 20 '13 at 13:59
  • See if any of the solutions in this other post can help you http://stackoverflow.com/questions/2161388/iframe-function-calling-from-iframe-to-parent-page-javascript-function – Vinod Aug 20 '13 at 14:19