Created
November 29, 2015 14:34
-
-
Save rootasjey/87e6cca1c0e37e1eb868 to your computer and use it in GitHub Desktop.
Demonstrates how to override back button (back navigation) on Windows 10 using WinJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------- | |
// Override Namespace | |
// ----------------- | |
WinJS.Namespace.define("override", { | |
// Add events on the page | |
init: WinJS.Class.define(function () { | |
WinJS.Navigation.addEventListener("beforenavigate", this.beforenavigate); | |
}), | |
// Execute additional code before navigation | |
beforenavigate: WinJS.Class.define(function (event) { | |
// This function gives you a chance to veto navigation. This demonstrates that capability | |
if (true /* should cancel navigation */) { | |
event.preventDefault(); | |
} | |
}) | |
}); | |
(function () { | |
"use strict"; | |
WinJS.UI.Pages.define("override.html", { | |
ready: function (element, options) { | |
// TODO: Called when the page is | |
override.init(); | |
}, | |
unload: function () { | |
// TODO: Fired when we navigate outside this page | |
}, | |
updateLayout: function (element) { | |
// TODO: Must be fired when the layout changes | |
}, | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment