다음을 통해 공유


onbackclick event

Raised when the users clicks the backbutton on a Windows Phone.

Syntax

<div data-win-control="WinJS.Application." data-win-options="{onbackclick : handler}" />
function handler(eventInfo) { /* Your code */ }
 
// addEventListener syntax
.addEventListener("backclick", handler);
.removeEventListener("backclick", handler);

Event information

Synchronous No
Bubbles Yes
Cancelable Yes

 

Event handler parameters

  • eventInfo
    Type: CustomEvent**

    An object that contains information about the event. The detail property of this object contains the following sub-properties:

    • detail.type
      A string that indicates the type of event.

Remarks

This event cannot be cancelled using the preventDefault method. The handler for this event needs to return true to indicate to external code that the event has been handled.

If you handle this event in your code, then the navigation stack does not attempt to handle it. For example, if this event is cancelled and the user clicks the backbutton from the app's home page, then they do not leave the app.

Cancelling the onbackclick event

var app = WinJS.Application;

app.onbackclick = function (evt) {
    
    // Code that handles event ...

    // Need to return true to cancel the default behavior of this event.
    return true;
}

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.Application