onbackclick event

Applies to Windows Phone only

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

SynchronousNo
BubblesYes
CancelableYes

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

None supported [Windows Store apps only]

Minimum supported server

None supported [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1

Namespace

WinJS.Application

Library

Base.js

 

 

Show:
© 2014 Microsoft