كيفية إغلاق نافذة تسجيل الدخول المنبثقة على Facebook بعد اتصال المستخدم؟

StackOverflow https://stackoverflow.com/questions/1610326

  •  05-07-2019
  •  | 
  •  

سؤال

أدناه هو الكود الخاص بي. لسبب ما ، بعد قيام المستخدم بتسجيل الدخول إلى النافذة المنبثقة الصغيرة ، ستعود النافذة الصغيرة إلى العودة إلى '/"مع الكثير من جلسة JSON غير المرغوب فيها في نهاية عنوان URL.

كيف أقوم بعملها حتى تغلق النافذة الصغيرة ، ويتم تحديث نافذة الوالدين؟

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script>

<fb:login-button v="2" onlogin='window.location("/test");' size="medium">Connect</fb:login-button>
<script type="text/javascript">FB.init("XXXXX",'/xd_receiver.htm');</script>
هل كانت مفيدة؟

المحلول 6

I solved it. It was to do with my settings in FAcebook's page.

نصائح أخرى

لقد قمت بحل مشكلة مماثلة ، أنه عند تسجيل الدخول باستخدام نافذة Facebook لتسجيل الدخول المنبثقة ، وتغلق الصفحة ، لم تنجح الصفحة.

لم يتم تكوين تطبيق Facebook الخاص بي بشكل صحيح. ما عليك سوى الانتقال إلى إعدادات التطبيق الخاصة بك في Facebook وحدد عنوان URL الصحيح للموقع (ضمن قسم موقع الويب). إذا كنت تختبرها محليًا يمكنك وضعها http: // localhost/

أتمنى أن يساعدك هذا!

Page Reloading

Try setting the reloadIfSessionStateChanged flag for FB.init. For example,

FB.init(  "myAPIkey", 
          "path/to/xd_receiver.htm",
          {"reloadIfSessionStateChanged": true}
       );

From the Facebook API

reloadIfSessionStateChanged

bool - If the value is true, Facebook will monitor changes in session state and reload the current page if the session state changes. This option is convenient for an implementation that needs to reload the page whenever session state change in order to generate different content from server side.

For more info check out http://developers.facebook.com/docs/?u=facebook.jslib.FB.Facebook.init

Popup Not Closing

I've found that you may have issues with your popup window not closing if your path/to/xd_receiver.html is incorrect, or if your onlogin function for your Connect Button is undefined, so be sure to double check those.

Hope that helps!

You can use the onlogin attribute this way:

onlogin="document.location.href=document.location.href;"

This will be executed by the opener (refreshing the page).
If you remove the onlogin attribute the pop up will also close, but the page below do not refresh.

I wrote a tutorial about integrating a community with facebook connect, you can read it here.

It looks like you have a random 'h' in your code. Could this be messing with the JS functionality?

FB.init("XXXXX",'/xd_receiver.htm'h);
                                  ^

My popup wasn't closing (when posting to a feed) because I didn't have the channel.html file in the right place. After doing the post it redirects to the channel.html file in order (partly) to close the popup - so not having it in the right place meant it didn't close.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top