You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creates an invisible anchor with a `_blank` target and clicks it.
589
-
Contrary to `window.open()`, this has a lesser chance to get blocked by the browser's popup blocker and doesn't open the URL as a new window.
590
-
This function has to be run in response to a user interaction event, else the browser might reject it.
588
+
Tries to use `GM.openInTab` to open the given URL in a new tab, or as a fallback if the grant is not given, creates an invisible anchor element and clicks it.
589
+
If `background` is set to true, the tab will be opened in the background. Leave `undefined` to use the browser's default behavior.
591
590
592
-
⚠️ This function needs to be run after the DOM has loaded (when using `@run-at document-end` or after `DOMContentLoaded` has fired).
591
+
⚠️ Needs the `@grant GM.openInTab` directive, otherwise only the fallback behavior will be used and the warning below is extra important:
592
+
⚠️ For the fallback to work, this function needs to be run in response to a user interaction event, else the browser might reject it.
593
593
594
594
<details><summary><b>Example - click to view</b></summary>
* Creates an invisible anchor with a `_blank` target and clicks it.
70
-
* Contrary to `window.open()`, this has a lesser chance to get blocked by the browser's popup blocker and doesn't open the URL as a new window.
71
-
*
72
-
* This function has to be run in response to a user interaction event, else the browser might reject it.
69
+
* Tries to use `GM.openInTab` to open the given URL in a new tab, otherwise if the grant is not given, creates an invisible anchor element and clicks it.
70
+
* For the fallback to work, this function needs to be run in response to a user interaction event, else the browser might reject it.
71
+
* @param href The URL to open in a new tab
72
+
* @param background If set to `true`, the tab will be opened in the background - set to `undefined` (default) to use the browser's default behavior
0 commit comments