PDA

View Full Version : Refreshing the parent window from pop up doesn't work with a Facebook login.



monaya
07-14-2011, 01:47 AM
I have a facebook login in a pop up window. When the user is logged in, I want it to refresh the parent window and close that pop up.

Refreshing my parent window doesnt work. Ive debugged and it works when i remove the facebook login and just pop up and empty page. It seems the trip to a different server for the facebook login in the popup breaks the connection between parent and child.

Is there any way to maintain that connection?

I'm opening a pop up with:


<a href="javascript:;" onClick="window.open('/fb/login/','fblogin','width=750,height=650')">

then I use this to refresh parent and close child window.


<script language="JavaScript">
<!--
window.parent.document.location.reload();
window.close();
//-->
</script>

jscheuer1
07-14-2011, 03:49 AM
<script language="JavaScript">
<!--
window.parent.document.location.reload();
window.close();
//-->
</script>

You can't do that because if it worked at all, that would execute right away - you'd never see the popup. And unless it's not a window (like an iframe or frame instead) it's not the parent, it's the opener. But then you couldn't close it anyway. What are you really doing?

But to answer the question, no. All modern browsers prevent cross domain scripting as a security measure. Since there's no way for them to tell when this is innocent or not, all cross domain scripting is blocked.

monaya
07-14-2011, 04:27 AM
Im doing a facebook connect app, so I open a pop up which works. In the pop up, the user logs in through fb. When that's done successfully, i set cookies and then I want to close that pop up and refresh the parent page so the cookies get reflected.

Everything works but the parent page isn't refreshing when the pop up closes so the user doesn't realize they're actually logged in

Here's an example http://talkupon.com/16 but you have to login to see what I mean

Its weird cause it worked at one point, but can't figure why it's not now.

monaya
07-14-2011, 02:41 PM
Instead of the headache i've just went ahead and changed the login from occurring in the popup to just go through in the same window.