Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reload top most window from iframe?

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!

like image 316
Javier Villanueva Avatar asked Dec 21 '22 14:12

Javier Villanueva


1 Answers

We reference the facebook parent page as top.

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

like image 120
dragonjet Avatar answered Dec 26 '22 20:12

dragonjet