GM.getValue: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m Text replace - "[[Metadata_block" to "[[Metadata Block" |
simplify |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
This | This method retrieves a value that was set with [[GM_setValue]]. | ||
See [[GM_setValue]] for details on the storage of these values. | |||
Compatibility: [[Version_history#0.3_beta|Greasemonkey 0.3b+]] | |||
== Syntax == | == Syntax == | ||
{{Function|GM_getValue|name, default}} | |||
=== Arguments === | |||
; <code>name</code> | |||
: <code>String</code> The property name to get. See [[GM_setValue#Arguments|GM_setValue]] for details. | |||
; <code>default</code> | |||
: | : Any value to be returned, when no value has previously been set. | ||
=== Returns === | |||
; When this <code>name</code> has been set | |||
: <code>String</code>, <code>Integer</code> or <code>Boolean</code> as previously set | |||
; When this <code>name</code> has not been set, and <code>default</code> is provided | |||
: The value passed as <code>default</code> | |||
; When this <code>name</code> has not been set, and <code>default</code> is not | |||
: <code>null</code> | |||
==== | == Examples == | ||
<pre class='sample'> | <pre class='sample'> | ||
GM_log(GM_getValue("foo")); | GM_log(GM_getValue("foo")); | ||
Line 51: | Line 36: | ||
== See Also == | == See Also == | ||
* [[GM_setValue]] | * [[GM_setValue]] | ||
* [[GM_deleteValue]] | * [[GM_deleteValue]] | ||
* [[GM_listValues]] | * [[GM_listValues]] | ||
[[Category:API_Reference|G]] | [[Category:API_Reference|G]] |
Revision as of 21:35, 8 February 2010
Description
This method retrieves a value that was set with GM_setValue. See GM_setValue for details on the storage of these values.
Compatibility: Greasemonkey 0.3b+
Syntax
function GM_getValue( name, default )
Arguments
name
String
The property name to get. See GM_setValue for details.default
- Any value to be returned, when no value has previously been set.
Returns
- When this
name
has been set String
,Integer
orBoolean
as previously set- When this
name
has not been set, anddefault
is provided - The value passed as
default
- When this
name
has not been set, anddefault
is not null
Examples
GM_log(GM_getValue("foo"));