WinJS.Application.addEventListener function
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: stringThe type (name) of the event. You can use any of the following:"activated", "checkpoint", "error", "loaded", "ready", "settings", and" unload".
listener
Type: functionThe listener to invoke when the event is raised.
capture
Type: Booleantrue to initiate capture, otherwise false.
Return value
This function does not return a value.
Remarks
The following events can be added with this function:
"activated": For more information, see WinJS.Application.onactivated.
"checkpoint": For more information, see WinJS.Application.oncheckpoint.
"error": For more information, see WinJS.Application.onerror.
"loaded": For more information, see WinJS.Application.onloaded.
"ready": For more information, see WinJS.Application.onready.
"settings": For more information, see WinJS.Application.onsettings.
"unload": For more information, see WinJS.Application.onunload.
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 |