addEventListener function

WinJS.Application.addEventListener function

Applies to Windows and Windows Phone

Adds an event listener for application-level events: activated, checkpoint, error, loaded, ready, settings, and unload.

Note  Listeners for some Windows Store app events, like "suspending" and "resuming", cannot be added with this function. You must use Windows.UI.WebUI.WebUIApplication.addEventListener instead. See the example for more details.
 

Syntax


WinJS.Application.addEventListener(type, listener, capture);

Parameters

type

Type: string

The type (name) of the event. You can use any of the following:"activated", "checkpoint", "error", "loaded", "ready", "settings", and" unload".

listener

Type: function

The listener to invoke when the event is raised.

capture

Type: Boolean

true to initiate capture, otherwise false.

Return value

This function does not return a value.

Remarks

The following events can be added with this function:

Examples

The following code shows how to add event listeners for different events.


WinJS.Application.addEventListener("activated", activated, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("suspending", suspending, false);
Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resuming, false);
WinJS.Application.addEventListener("unload", activated, false);

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Application

 

 

Show:
© 2016 Microsoft