Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 420
Tool Avatar asked Jul 06 '16 04:07

Tool


People also ask

How do I close Firefox?

So far the only way to close fire fox is to click on the shut down button or to end it through the task manger. when I re-open Firefox the windows and previous tabs are also there, and I am still unable to close them.

Can a tab/window silently close?

(IE also allows HTA documents to close themselves without restriction.) In all other circumstances, the tab/window will not silently close: instead, the user is presented with a one of two modal dialogs, depending on whether the page represents the only tab in the browser window:

How do I fix Firefox not opening in safe mode?

On Windows: Hold the Shift key when you open the Firefox desktop or Start menu shortcut. On Mac: Hold the option key while starting Firefox. When the Firefox Safe Mode window appears, select "Start in Safe Mode". If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, theme, or hardware acceleration.

When does window close() work in chromium?

As of Chromium 88, window.close () succeeds if the new window/tab has an opener or if the back/forward stack contains fewer than two entries. As you can see, there are subtle differences here between what the spec requires and what the browser implements. First, notice that I said “has an opener” rather than “was created by a script.”


1 Answers

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>
like image 78
Jimadine Avatar answered Oct 21 '22 00:10

Jimadine