Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

initStorageEvent method

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

Internet Explorer 9

 

Syntax

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

Parameters

eventType [in]

Type: String

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

storage

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

Type: HRESULT

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

Standards information

  • , Section 4.4.1

Examples

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');
    evt.initStorageEvent('storage',false,false,'key','oldValue','newValue',
        'http://fabrikam.com/alleged.html',window.sessionStorage);
    window.dispatchEvent(evt);
}
function reportStorage(evt) {
    alert("Storage was updated for " + evt.url);
}
window.onload = function() {
    window.addEventListener('storage',reportStorage,false);
}
</script>
<button onclick="createStorageEvent()">Create a storage event</button> 

See also

StorageEvent

 

 

Show:
© 2017 Microsoft