Facebook的JavaScript的SDK窗口位置重新加载不工作在Firefox [英] Facebook Javascript SDK window location reload not working on Firefox

查看:182
本文介绍了Facebook的JavaScript的SDK窗口位置重新加载不工作在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Facebook Connect建立一个网站,因此使用Facebook Javascript SDK。
问题:使用Firefox时,页面在登录或注销后无法正确重新加载。

  FB.Event.subscribe(
'{%if current_user%} auth.logout {%else%} auth .login {%endif%}',
function(response){
window.location.reload();
});

显然,它看起来像一个已知的问题(只需键入窗口位置重新加载不工作在Firefox上和你会得到很多结果)

更确切地说,Firefox重新加载页面时似乎没有发送正确的cookie ...

- 当我点击登录时,一旦Facebook登录并设置了一个cookie,Firefox不会发送任何cookie。
- 当我点击注销时,一旦Facebook注销我并删除cookie,Firefox会发送之前存在的cookie。
我推断它使用了一些缓存功能。


我试图按照这里所述的方法来解决这个问题,并实现了这个功能: / p>

  redirect_url = encodeURIComponent(window.location.href); 
url = window.location.href +account / login?redirect_url =+ redirect_url;
window.location.replace(url);

但问题仍然存在(缓存我猜...)你能帮我解决这个问题吗?



谢谢。

解决方案

尝试封装window.location.reload ()以一个零延迟的方式调用setTimeout()。显然,在设置cookie之前,Firefox会触发事件。包装应将重新调用放入事件队列中,并允许cookies正确设置。


I'm building a website with Facebook Connect and therefore using the Facebook Javascript SDK. Problem: when using Firefox, the page doesn't reload properly once logged in or logged out.

FB.Event.subscribe(
   '{% if current_user %}auth.logout{% else %}auth.login{% endif %}',
    function(response){
        window.location.reload();
});

Obviously, it looks like a known problem (just type "window location reload not working on firefox" and you'll get a lot of results)

More precisely, Firefox doesn't seem to send the right cookie when reloading the page...
- When I click to login, once Facebook logged me in and sets a cookie, Firefox doesn't send any cookie
- When I click to logout, once Facebook has logged me out and remove the cookie, Firefox sends the cookie that was previously there.
I conclude it uses some "cache functions".

I tried to make a workaround as described here and implemented this:

redirect_url = encodeURIComponent(window.location.href);
url = window.location.href + "account/login?redirect_url=" + redirect_url;
window.location.replace(url);

But the problem remains (the cache I guess...) Can you help me out with this?

Thanks.

解决方案

Try wrapping the window.location.reload() call in a setTimeout() with a zero delay. Apparently, Firefox fires the event before setting the cookie. The wrapping should place the reload call in the event queue and allow the cookies to be set correctly.

这篇关于Facebook的JavaScript的SDK窗口位置重新加载不工作在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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