问题
I'm developing a facebook app which has the following "structure":
Browser window (facebook.com/page/xxxx)
-- My app's iframe
-- Like button's iframe
I'm using a Like button within my app so that's an iframe inside an iframe, when the users clicks on the like button I'd like to show the content so the page currently looks somethin like this:
if ( is_fan() ) {
//show content
} else {
//show like button plus other text
}
The actual logic to check if the user is already a fan is working as intended, the problem is that when I click the like button I need the whole page to reload in order to show the "fan content", if I do this:
FB.Event.subscribe('edge.create', function(href, widget) {
top.location.reload();
});
The page seems to reload but everything stays the same, but if I click "Like" and the click the refresh button in my browser everything shows up just fine.
Can anyone help me figure this out?
Thanks in advance!
回答1:
We reference the facebook parent page as top
.
use top.location.href="";
or top.location.reload();
回答2:
Neither top.location.href="";
or top.location.reload();
worked for me.
I had to use top.location.href="http://www.facebook.com/appurl";
回答3:
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 by you can force the the reload to get the page from server by setting the forceGet parameter to true: location.reload(true).
回答4:
To reload you could use top.location.href = top.location.href;
来源:https://stackoverflow.com/questions/5943894/how-to-reload-top-most-window-from-iframe