Skip to content

Feature Request:GM_CloseTab #1685

Open
Capatcha opened this Issue Jan 6, 2013 · 2 comments

3 participants

@Capatcha
Capatcha commented Jan 6, 2013

Open a new Tab with Greasemonkey:
var mynewopentab = GM_openInTab("http://www.example.com/");

Later close the previus opened tab.
GM_closeTab(mynewopentab);

I would not like to allow all javascript code to close windows with setting in about:config.
Only the GM Script should could do that.

@LouCypher

GM_openInTab returns window object so you can use close() method to close the tab.

// Open a tab
var mynewopentab = GM_openInTab("http://www.example.com/");

// Close it
mynewopentab.close();
@BrockA
BrockA commented Nov 16, 2014

GM_openInTab returns window object so you can use close() method to close the tab.

This is not true. You will get the error: "Scripts may not close windows that were not opened by script."

-- especially if the tab is cross-domain.

The only way around this, so far, is to cripple your browser's security by setting allow_scripts_to_close_windows to true in about:config (not recommended).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.