I had an annoying issue with window.open() on Webkit browsers (actually browsers that blocked popups). The issue was that I needed to open a new window for Facebook Connect or Twitter authentication. However, the problem with Webkit browsers is that the popup must IMMEDIATELY occur after the action is triggered.
In reality, that statement is a misnomer. The thing about the popup is that you cannot have certain activities going on, namely network activities. I was doing something stupid where I needed to make certain AJAX calls prior to invoking window.open(). However, at first I didn’t realize that the asychronous nature of the AJAX calls was preventing window.open() on the browser side. In one case, I was doing an FB.getLoginStatus() just prior to FB.login(). That normally might make sense depending on the circumstance. But I realized afterwards that my assumptions in doing that were incorrect and that I just needed to call FB.login(), which invokes a popup style window.
Similarly, with Twitter, I was retrieving the authentication url via an AJAX call and attempting to inject it into the window.open() url parameter. That was just plain dumb. Instead, I re-wrote my stuff so that window.open() loads up a url that contains a redirect to Twitter’s authentication page.
The thing is that the whole situation had me banging on my head all day long, especially when the logic of my login screen was working in a similar fashion but two other sections were not. Now, everything makes more sense.
Leave a Reply
You must be logged in to post a comment.