Skip to content

Instantly share code, notes, and snippets.

@rootasjey
Created November 29, 2015 14:34
Show Gist options
  • Save rootasjey/87e6cca1c0e37e1eb868 to your computer and use it in GitHub Desktop.
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
// -----------------
// 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