-2

I am trying to open a window (or new tab) (page B) via a button on page A. On page B, the user needs to complete a form and then rederect to page A. But I can't catch any event on page B from page A. How do I know when the user has submitted or closed page B?

My English is pretty bad, if you can't understand what I want to say, try the 'Login with Facebook' function of Pinterest.com. That's exactly what I need.Thanks you.

<a href="login.php" target="_blank">Open login page!</a> 

And page B:

<form id="somelink" method="post" action="" />
<input type="text" name="asd">
<button>Submit</button>

</form>

Sorry for not adding my code sooner, I think it's quite simple and not really necessary because it can make people misunderstand me. I really don't know how to put it this way, this is the first time I need it. The best way to visualize is to go to Pinterest's 'Login with Facebook'. enter image description here

Mido
  • 341
  • 2
  • 15

1 Answers1

1

I'm guessing Pinterest are using the offical Facebook javascript SDK. Read more here: https://developers.facebook.com/docs/facebook-login/web/#login

A quick reference from the documentation...

Step 1: Include the JavaScript SDK on your page once, ideally right after the opening body tag.

<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v5.0"></script>

Step 2: Place this code wherever you want the plugin to appear on your page.

<div class="fb-login-button" data-width="" data-size="large" data-button-type="continue_with" data-auto-logout-link="false" data-use-continue-as="false"></div>

If I've missunderstood the question and you're actually trying to implement your own version of similar functionality, check out this question Capture the close event of popup window in JavaScript

Levi Cole
  • 3,561
  • 1
  • 21
  • 36
  • Thanks you, I wasted 5 hours for this problem until you let me know it could be solved with a JavaScript code. Thanks. – Mido Nov 25 '19 at 15:45