GM.deleteValue: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m →Examples: fix formatting, and make the code actually work (for..in iterates keys, on an array this is broken as used) |
m added descriptions to code examples; |
||
Line 3: | Line 3: | ||
== Description == | == Description == | ||
This method deletes an existing | This method deletes an existing name / value pair from storage. | ||
See [[GM_setValue]] for details | |||
See [[GM_setValue]] for details regarding the storage of these values. | |||
== Syntax == | == Syntax == | ||
Line 15: | Line 16: | ||
; <code>name</code> | ; <code>name</code> | ||
: Property name to delete. See [[GM_setValue#Arguments|GM_setValue]] for details. | : Property name to delete. See [[GM_setValue#Arguments|GM_setValue]] for details on what names are valid. | ||
== Returns == | == Returns == | ||
Line 23: | Line 24: | ||
== Examples == | == Examples == | ||
Delete the stored name / value pair that has the name 'foo': | |||
<pre class='sample'> | <pre class='sample'> | ||
GM_deleteValue("foo"); | GM_deleteValue("foo"); | ||
</pre> | </pre> | ||
Example showing the use of [[GM_listValues]] to delete ''all'' stored name / value pairs: | |||
<pre class='sample'> | <pre class='sample'> | ||
var keys = GM_listValues(); | var keys = GM_listValues(); |
Revision as of 00:42, 11 May 2011
Description
This method deletes an existing name / value pair from storage.
See GM_setValue for details regarding the storage of these values.
Syntax
function GM_deleteValue( name )
Compatibility: Greasemonkey 0.8.1+
Arguments
name
- Property name to delete. See GM_setValue for details on what names are valid.
Returns
undefined
Examples
Delete the stored name / value pair that has the name 'foo':
GM_deleteValue("foo");
Example showing the use of GM_listValues to delete all stored name / value pairs:
var keys = GM_listValues(); for (var i=0, key=null; key=keys[i]; i++) { GM_deleteValue(key); }
See Also
Notes
An issue that some may encounter on some platforms is that the values appear to not be deleted or set. This is usually due to a refreshing issue in the browser. If about:config is refreshed in the window/tab this should resolve any questions about stability of setting and deleting system preferences.