WinJs: How to navigate to another start page programatically? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of WinJs: How to navigate to another start page programatically? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

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:

default.js

    var p = WinJS.UI.processAll().then(function () {
           WinJS.Navigation.navigate('/pages/login.html');
    });

Answer

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.

We are here to answer your question about WinJs: How to navigate to another start page programatically? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji