如何从IFRAME刷新最上面的窗口? [英] how to reload top most window from iframe?

查看:162
本文介绍了如何从IFRAME刷新最上面的窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发其具有以下结构一个Facebook应用程序:

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

我使用一个Like按钮我的应用程序中,这样是一个iframe中的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.

谁能帮我算出这个?

在此先感谢!

推荐答案

我们引用作为Facebook的父页面

We reference the facebook parent page as top.

使用 top.location.href =; top.location.reload();

这篇关于如何从IFRAME刷新最上面的窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆