StorageEvent

  • Revision slug: Web/API/StorageEvent
  • Revision title: StorageEvent
  • Revision id: 493049
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Replaced Gecko_callout_header macro with a simple note

Revision Content

{{ IFSummary("dom/interfaces/storage/nsIDOMStorageEvent.idl", "nsIDOMEvent", "Scriptable", "2.0", "Describes an event occurring on HTML5 client-side storage data.", "2.0") }}

A StorageEvent is sent to a window when a storage area changes.

Note:Although this event existed prior to {{ Gecko("2.0") }}, it did not match the specification. The old event format is now represented by the {{ interface("nsIDOMStorageEventObsolete") }} interface.

Method overview

void initStorageEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, in nsIDOMStorage storageAreaArg);

Attributes

Attribute Type Description
key DOMString Represents the key changed. The key attribute is null when the change is caused by the storage clear() method. Read only.
newValue DOMString The new value of the key. The newValue is null when the change has been invoked by storage clear() method or the key has been removed from the storage. Read only.
oldValue DOMString The original value of the key. The oldValue is null when the change has been invoked by storage clear() method or the key has been newly added and therefor doesn't have any previous value. Read only.
storageArea {{ Interface("nsIDOMStorage") }} Represents the Storage object that was affected. Read only.
url DOMString The URL of the document whose key changed. Read only.

Methods

initStorageEvent()

Initializes the event in a manner analogous to the similarly-named method in the DOM Events interfaces.

void initStorageEvent(
  in DOMString typeArg,
  in boolean canBubbleArg,
  in boolean cancelableArg,
  in DOMString keyArg,
  in DOMString oldValueArg,
  in DOMString newValueArg,
  in DOMString urlArg,
  in nsIDOMStorage storageAreaArg
);
Parameters
typeArg
The name of the event.
canBubbleArg
A boolean indicating whether the event bubbles up through the DOM or not.
cancelableArg
A boolean indicating whether the event is cancelable.
keyArg
The key whose value is changing as a result of this event.
oldValueArg
The key's old value.
newValueArg
The key's new value.
urlArg
Missing Description
storageAreaArg
The DOM {{ domxref("Storage") }} object representing the storage area on which this event occurred.

See also

Revision Source

<p>{{ IFSummary("dom/interfaces/storage/nsIDOMStorageEvent.idl", "nsIDOMEvent", "Scriptable", "2.0", "Describes an event occurring on HTML5 client-side storage data.", "2.0") }}</p>
<p>A <code>StorageEvent</code> is sent to a window when a storage area changes.</p>
<div class="note">
 <p><strong>Note:</strong>Although this event existed prior to {{ Gecko("2.0") }}, it did not match the specification. The old event format is now represented by the {{ interface("nsIDOMStorageEventObsolete") }} interface.</p>
</div>
<h2 id="Method_overview" name="Method_overview">Method overview</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <td><code>void <a href="#initStorageEvent()">initStorageEvent</a>(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, in nsIDOMStorage storageAreaArg);</code></td>
  </tr>
 </tbody>
</table>
<h2 id="Attributes" name="Attributes">Attributes</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <td class="header">Attribute</td>
   <td class="header">Type</td>
   <td class="header">Description</td>
  </tr>
  <tr>
   <td><code>key</code></td>
   <td><code><a href="/en/DOMString" title="en/DOMString">DOMString</a></code></td>
   <td>Represents the key changed. The <code>key</code> attribute is <code>null</code> when the change is caused by the storage <code>clear()</code> method. <strong>Read only.</strong></td>
  </tr>
  <tr>
   <td><code>newValue</code></td>
   <td><code><a href="/en/DOMString" title="en/DOMString">DOMString</a></code></td>
   <td>The new value of the <code>key</code>. The <code>newValue</code> is <code>null</code> when the change has been invoked by storage <code>clear()</code> method or the <code>key</code> has been removed from the storage. <strong>Read only.</strong></td>
  </tr>
  <tr>
   <td><code>oldValue</code></td>
   <td><code><a href="/en/DOMString" title="en/DOMString">DOMString</a></code></td>
   <td>The original value of the <code>key</code>. The <code>oldValue</code> is <code>null</code> when the change has been invoked by storage <code>clear()</code> method or the <code>key</code> has been newly added and therefor doesn't have any previous value. <strong>Read only.</strong></td>
  </tr>
  <tr>
   <td><code>storageArea</code></td>
   <td><code>{{ Interface("nsIDOMStorage") }}</code></td>
   <td>Represents the Storage object that was affected. <strong>Read only.</strong></td>
  </tr>
  <tr>
   <td><code>url</code></td>
   <td><code><a href="/en/DOMString" title="en/DOMString">DOMString</a></code></td>
   <td>The URL of the document whose <code>key</code> changed. <strong>Read only.</strong></td>
  </tr>
 </tbody>
</table>
<h2 id="Methods" name="Methods">Methods</h2>
<h3 id="initStorageEvent()" name="initStorageEvent()">initStorageEvent()</h3>
<p>Initializes the event in a manner analogous to the similarly-named method in the DOM Events interfaces.</p>
<pre class="eval">
void initStorageEvent(
  in DOMString typeArg,
  in boolean canBubbleArg,
  in boolean cancelableArg,
  in DOMString keyArg,
  in DOMString oldValueArg,
  in DOMString newValueArg,
  in DOMString urlArg,
  in nsIDOMStorage storageAreaArg
);
</pre>
<h6 id="Parameters" name="Parameters">Parameters</h6>
<dl>
 <dt>
  <code>typeArg</code></dt>
 <dd>
  The name of the event.</dd>
 <dt>
  <code>canBubbleArg</code></dt>
 <dd>
  A boolean indicating whether the event bubbles up through the DOM or not.</dd>
 <dt>
  <code>cancelableArg</code></dt>
 <dd>
  A boolean indicating whether the event is cancelable.</dd>
 <dt>
  <code>keyArg</code></dt>
 <dd>
  The key whose value is changing as a result of this event.</dd>
 <dt>
  <code>oldValueArg</code></dt>
 <dd>
  The key's old value.</dd>
 <dt>
  <code>newValueArg</code></dt>
 <dd>
  The key's new value.</dd>
 <dt>
  <code>urlArg</code></dt>
 <dd>
  Missing Description</dd>
 <dt>
  <code>storageAreaArg</code></dt>
 <dd>
  The DOM&nbsp;{{ domxref("Storage") }} object representing the storage area on which this event occurred.</dd>
</dl>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>&nbsp;<a class="external" href="http://dev.w3.org/html5/webstorage/#the-storage-event" title="http://dev.w3.org/html5/webstorage/#the-storage-event">Specification</a></li>
</ul>
Revert to this revision