initStorageEvent method

Initializes a new Document Object Model (DOM) storage event that the createEvent method created.

Internet Explorer 9



var retval = StorageEvent.initStorageEvent(eventType, canBubble, cancelable, keyArg, oldValueArg, newValueArg, urlArg, storageAreaArg);


eventType [in]

Type: String

The following value, or a user-defined custom event type:


An onstorage event.

canBubble [in]

Type: Boolean

true (true)

The event should propagate upward.

false (false)

The event does not propagate upward.

cancelable [in]

Type: Boolean

true (true)

The default action can be canceled.

false (false)

The default action cannot be canceled.

keyArg [in]

Type: String

The storage key. This value is returned in the key attribute of the event.

oldValueArg [in]

Type: String

The previous value of the storage key, or null. This value is returned in the oldValue attribute of the event.

newValueArg [in]

Type: String

The new value of the storage key, or null. This value is returned in the newValue attribute of the event.

urlArg [in]

Type: String

The address of the document that is processing the event. This value is returned in the url attribute of the event.

storageAreaArg [in]

Type: IHTMLStorage

The Storage object that is modified. This value is returned in the storageArea attribute of the event.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

  • , Section 4.4.1


The following code example demonstrates how to create and dispatch a custom storage event.

<script type="text/javascript">
function createStorageEvent() {
    var evt = document.createEvent('StorageEvent');
function reportStorage(evt) {
    alert("Storage was updated for " + evt.url);
window.onload = function() {
<button onclick="createStorageEvent()">Create a storage event</button> 

See also