WinJs: How to navigate to another start page programatically?

Let’s say I want to display a login screen before going into the app’s main screen

This does not work and I don’t understand why:


    var p = WinJS.UI.processAll().then(function () {


WinJS.Navigation.navigate is merely a mechanism to raise navigation events. Some other piece of code has to handle those events to do the actual page loading. Without such code, the WinJS.Navigation APIs do nothing on their own.

With the usual Store app templates in Visual Studio, there’s a navigator.js file that provides this boilerplate code and works with pages you’ve defined with WinJS.Pages.define.

If you are using navigator.js already, then check that the path you give to navigate exactly matches a path given to WinJS.Pages.define. If there’s a mismatch, the page will fail to load.

I’d point you to the MSDN docs on doing page navigation, but all of that’s moving around in advance of Windows 10 so the links I know about are broken. But you can refer to Chapter 3 of my free ebook, Programming Windows Store Apps with HTML, CSS, and JavaScript, 2nd Edition, for all the details.

Leave a Reply

Your email address will not be published. Required fields are marked *