EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

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 supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Application

Library

Base.js

 

 

Afficher:
© 2014 Microsoft