GM.openInTab: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
Marti (talk | contribs)
m Undo revision 4138 by Aavindraa (Talk) Restored "sensical" statement
Update for 4.0
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{underscore|title=GM_openInTab}}
__NOTOC__
{{Greasemonkey Manual TOC}}
== Description ==
== Description ==


This [[API_reference|API]] method opens the specified URL in a new background tab.
This method opens the specified URL in a new tab.


[[#Examples|Examples]] | [[#Notes|Notes]]
== Syntax ==


== Syntax ==
{{Function|GM.openInTab|url, open_in_background}}


'''GM_openInTab(''' ''url'' ''')'''
Compatibility: [[Version_history#4.0_2|Greasemonkey 4.0+]]


:Value: Function
=== Arguments ===
:Returns: undefined
:Compatibility: [[Version_history#0.5_beta|Greasemonkey 0.5b+]]


:{| cellpadding="5" style="border-style:solid; background:#FFFFE0;"
; <code>url</code>
|+ Parameters
: <code>String</code> The URL to navigate the new tab to.
!style="background:#CC9900;"|'''Properties'''
; <code>open_in_background</code>
|-
: <code>Boolean</code> Optional: force tab to/to not open in a background tab.  Default (unspecified) behavior honors Firefox configuration.
| <code><span style="background:#FFFFE0;">[[#url |url]]</span></code>
|}
:* All properties are optional except [[#url|url]].


[[#top|top]]
== Returns ==
=== Properties ===
----
==== <code>url</code> ====
:Value: String
:Usage: <code>'''url''' = "<nowiki>http://www.greasespot.net/</nowiki>";</code>


[[#top|top]] | [[#Syntax|back]]''
<code>undefined</code>


== Examples ==
== Examples ==
{{Core samp |1=<pre style="border: none; margin: inherit;">
GM_openInTab("http://www.greasespot.net/");
</pre>}}
[[#top|top]]
== Notes ==
=== Referrer Issue ===
Opening webpages by invoking this method may not be the ideal choice, because this method doesn't save the referring page, which makes webservers think that you are calling a page only by it's URL, and not from the webpage it was on.
In the cases where it doesn't work, one may use <code>window.open(url)</code> instead, which is similar in that it opens a new tab, but it keeps the referrer and switches to the tab immediately.


[[#top|top]]
<pre class='sample'>
GM.openInTab("http://www.example.com/");
</pre>


[[Category:API_Reference|O]]
[[Category:API_Reference|O]]

Latest revision as of 15:05, 3 November 2017

Description

This method opens the specified URL in a new tab.

Syntax

function GM.openInTab( url, open_in_background )

Compatibility: Greasemonkey 4.0+

Arguments

url
String The URL to navigate the new tab to.
open_in_background
Boolean Optional: force tab to/to not open in a background tab. Default (unspecified) behavior honors Firefox configuration.

Returns

undefined

Examples

GM.openInTab("http://www.example.com/");