How to reload top window from iframe?

I am developing a facebook application that has the following “structure”:

Browser window (facebook.com/page/xxxx) -- My app iframe -- Like button iframe 

I use the Like button in my application so that the iframe inside the iframe, when users click on a similar button, I would like to show the contents so that the page currently looks something like this:

 if ( is_fan() ) { //show content } else { //show like button plus other text } 

The actual logic for checking if the user is already a fan works as intended, the problem is that when I click on a similar button, I need the whole page to reload to show the “fan content” if I do this:

 FB.Event.subscribe('edge.create', function(href, widget) { top.location.reload(); }); 

It seems that the page is reloading, but everything remains the same, but if I click "Like" and click the "Refresh" button in my browser, everything will be clearly visible.

Can someone help me figure this out?

Thanks in advance!

+4
source share
4 answers

We link to the parent facebook page as top .

use top.location.href=""; or top.location.reload();

+7
source

Not for me top.location.href=""; or top.location.reload(); .

I had to use top.location.href="http://www.facebook.com/appurl";

+2
source

Try top.location.reload(true); instead of top.location.reload();

Extracted from http://www.w3schools.com/jsref/met_loc_reload.asp :

By default, the location.reload () method reloads from the cache, but you can force the reload to get the page from the server by setting the forceGet parameter to true: location.reload (true).

+2
source

For rebooting, you can use top.location.href = top.location.href;

0
source

All Articles