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:
-
"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 supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
WinJS.Application |
|
Library |
|
Build date: 12/5/2012