Close multiple firefox windows from javascript - javascript

I have a GWT application which has many firefox windows. I need functionality to close all these windows with a single click on a button. I know the window.close() function, but it only closes the current window.
I wonder if there is a firefox plugin or anything what can help me achieve this functionality.
In Firefox the File menu contains an Exit button what terminates the program, but i can't find a way to call this from javascript.

You cannot close other windows with script that didn't open them. But
var newWindow = window.open( url );
newWindow.close();
will open new tab with url and then you will be able to close it with newWindow.close();

When a new window is opened with window.open(), a reference to the new window is returned.
This means var window1 = window.open("example.com", "windowName"); will allow you to close the this new window later with window1.close();
Windows are often opened this way to address your problem, though if the windowName specified existed already, the existing window would be used to load the page instead, and the variable would refer to the existing window.
EDIT: This explains browser windows and associated window control JavaScript here

Related

How to close a url/website/tab using google chrome add-on?

So, imagine a person opening an online gaming website(for example krunker.io) in chrome, and what I want to know is whether there is a way to detect if a url(in this case "https://krunker.io/*") is open and to immediately close the tab(or the browser) using a Google Chrome addon(or even an outside application is fine).
The window.close() method does not work, as the person him/herself is the one who opens the tab/window, not the application
To close a tab, you can use the chrome.tabs.remove method.
// retrieve the id of the tab to close
$tabToCloseId = retrieveIdOfTabToClose(); //To write by yourself
chrome.tabs.remove($tabToCloseId);

How to open a new tab in separate thread with JavaScript? (chrome)

Is it possible to open a new popup tab that would run in a separate thread? To be more specific, if I create a new popup tab and start debugging in that new tab, tab which contains link will also pause javascript until I click resume in a new tab. What I want to achieve is to create a new tab that is separated so I can debug it while parent tab continues running.
I have this problem using Chrome browser. Note that this works fine in Firefox (haven't tested in other browsers).
Usually chrome forces new window to run on the same Process ID.
But, there are techniques which allows sites to open a new window without forcing it into the same process:
Use a link to a different web site that targets a new window without passing on referrer information.
Open in new tab and new process
If you want the new tab to open in a new process while still passing on referrer information, you can use the following steps in JavaScript:
Open the new tab with about:blank as its target.
Set the newly opened tab's opener variable to null, so that it can't access the original page.
Redirect from about:blank to a different web site than the original page.
For example:
var w = window.open();
w.opener = null;
w.document.location = "http://differentsite.com/index.html";
Technically the original website still has access to the new one through w, but they treat .opener=null as a clue to neuter the window.
Source: https://bugzilla.mozilla.org/show_bug.cgi?id=666746
The current version of Chrome does not appear to use a separate thread when using the null opener trick that domagojk referenced. However, if you're in a javascript handler you can still take advantage of the noreferrer link trick he mentions:
var e = document.createElement("a");
e.href="/index.html";
e.target="_blank";
e.rel = "noreferrer";
e.click();
Have you tried using Web Workers? Not sure about support, but they're supposed to offer parallel JS execution functionality. See here and here.
While not exactly an answer, to me it is the best answer. The print dialog should not be blocking.
I have reported this as a bug and given a test case. Show your support at here - https://bugs.chromium.org/p/chromium/issues/detail?id=1023161&q=ryein%20goddard&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified
I think once Chromium fixes this bug we won't have to worry about it any more. It is really the only choice at this point.
So to me the answer is we need Google/Chromium to fix this issue.

Close popups created with window.open in IE11

I have Ie 11 to support. I open the popup using var myWindow = window.open('url','name','width=640,height=480,menubar=no,toolbar=no');
however, the handle returned (myWindow) is always null in ie.
I need to close that popup after certain events happen.
I know that it is possible because I've seen other sites do that in the same browser.
Any ideas?
If window.open() is returning null, then something is wrong. You're likely blocking popups, which means that the Window object will not be created (and thus myWindow will be null).
Check your security settings there and enable them.
Once you get window.open() to execute successfully, you can call myWindow.close() to close the popup when necessary. Note that the close() method can only close popups that have been opened using the window.open() method.

resizeTo() not working in Firefox

Running Firefox 12.0. I'm just starting to write a app that I want to run on localhost. I want it to open it in a (600,400) window, but since I have Firefox set to open everything in tabs I thought I could bookmark it and right-click to open it in a new window.
$(document).ready(function() {
window.resizeTo(600,400);
});
Doesn't work. Is what I am trying to do possible?
Thanks, Jim
This isn't possible, unless the window was opened through javascript using window.open and has only 1 tab in it.
Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser, according to the following rules:
- You can't resize a window or tab that wasn’t created by window.open.
- You can't resize a window or tab when it’s in a window with more than one tab.
MDN docs

new window or tab is opened now, How can i check it

How can i check that the new window or tab is opened or exited now of same site ,so i can store/destroy some values in session variable accordingly.
If its possible in php then best then better.
I am using mostly IE 6.0 and above.
Thanks a lot.
Obviously i haven't tried this in IE but it should be a standard
when you open a window in your script, you can still control it.
var win = window.open("http://example.com");
if (win) {
// the window is open.
// you can close it with the close method
win.close();
}

Categories

Resources