when i click on link from my extension, i open a popup window as shown below:
After Login, how can i close a browser window?
when i click on link from my extension, i open a popup window as shown below:
After Login, how can i close a browser window?
Have you tried calling window.close()
inside the popup?
yes… i have tried window.close(), but its not working…
but its not working
That is strange. I just successfully did that in both Chrome and Firefox. Are you calling .close()
on the top-level frame (and not inside an embedded iframe)?
An alternative approach would be:
async function closeSelf() {
const { id: windowId, } = (await browser.windows.getCurrent());
return browser.windows.remove(windowId);
}
thank you for help
window.close() is working now. Actually in my browser allow_scripts_to_close_windows is in false mode . I set it TRUE.
for all browsers allow_scripts_to_close_windows is false by default. Is there any option to close window?
otherwise how can we, allow_scripts_to_close_windows is to true programatically?
You can’t (and shouldn’t) change that from a WebExtension.
Is there anything wrong with the closeSelf
function I proposed?
closeSelf is not working for me…could you please provide the code syntax , how to close window for closeSelf ?
My code: for open a window
browser.windows.create({
url: browser.extension.getURL(“Login.htm”),
type: “popup”,
height: 600,
width: 500
});
then window.close is not working…
If you declare and call closeSelf
inside that popup it will work. (And window.close()
should too.)
this is working in FF 71/70