Tool
Tool

Reputation: 12488

window.close doesn't work if window is opened as tab (Firefox 47)

var google_login_popup = "";

var social_google_login = function () {

    google_login_popup = window.open('www.google.com', "google_popup", 'width=800, height=600');

};

social_google_login();

setTimeout(function() {
  google_login_popup.close();
}, 1000);

It opens the popup in a new TAB - not window. But .close() doesn't close the window.

This should work as the script opening the window is also trying to close it.

Note that this only applies for Firefox 47, mobile.

Video: https://www.dropbox.com/s/bqcf8iwm5bsw4yn/VIDEO0254.mp4?dl=0.

Upvotes: 7

Views: 293

Answers (1)

Jimadine
Jimadine

Reputation: 1064

I tested this in Firefox 47 on mobile (Android 5.1.1, Moto G) and wasn't able to replicate the behaviour using your code in a skeleton web page. However, looking at the video and looking at the code in https://cdn.dorms.com/static/js/social.js there's clearly more going on than just the code you've supplied here on SO.

Suggestions for the person with the device

  • Try out some skeleton code or use my page at https://www.dropbox.com/s/db08g2gmn9s8i89/38216372.html?dl=0 † to see if you can reproduce the problem.
  • Prefix the popup URL with http:// or https:// and/or make the timeout longer. I doubt very much this will help but there may be some weirdness going on.
  • Reset the Firefox app, if this okay with the device owner. Clear app data and start again, just to make sure there isn't something lurking.
  • Firefox mobile does have USB and Wi-fi remote debugging capabilities - check under Settings >> Advanced >> Scroll to the bottom to "learn more". This would really save time trying to debug this.

† My page contains the following HTML:

<!DOCTYPE html>
<html>
<head>
<title>Test web page</title>
<script>
var google_login_popup = "";
var social_google_login = function () {

    google_login_popup = window.open('www.google.com', "google_popup", 'width=800, height=600');

};
social_google_login();
setTimeout(function() {
  google_login_popup.close();
}, 1000);
</script>
</head>
<body>Test web page</body>
</html>

Upvotes: 1

Related Questions