Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:28:02+00:00 2026-06-11T15:28:02+00:00

Ello! I have an app bar icon and on the click event – I

  • 0

Ello!

I have an app bar icon and on the click event – I added a function which has the following code:

function homePage() {

    WinJS.Navigation.navigate("/home/homePage.html");

}

Now I have two files – homePage.html which is inside /home/ and the js file for the same.

There’s a simple button on html of id NextPage.

While in the homePage.js file, I have:

function () {
    "use strict";

    WinJS.UI.Pages.define("/home/homePage.html", {
        ready: function (element, options) {
           var button = document.getElementById("NextPage");
           button.addEventListener("click", GoToNextPage);
        }
    });
    function GoToNextPage() {
        WinJS.Navigation.navigate("/default.html");
    }

})(); 

But when I click the app bar icon – nothing happens 🙁

So what I plan to accomplish is that when someone clicks an appbar icon on default.html – the user switches to homePage.html (and then when I click the homePage button – it goes back) – but not even the initial page transfer is taking place.

This is embarrassing to ask but I can’t just fold my hands and wait for something magical to happen. I have been working on this for an hour – read videos and samples but it’s not working at all.

Would appreciate help – I can’t figure out what’s going wrong. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:28:03+00:00Added an answer on June 11, 2026 at 3:28 pm

    The WinJS.Navigation namespace provides state and history management, but it doesn’t actually do the navigation itself. To move from one page to another, you need to define a handler function for one of the events in the WinJS.Navigation namespace – this lets you respond to call to the WinJS.Navigation.navigate method in a way which makes sense for your app.

    As a demonstration, here is a homePage.html file which has a NavBar containing a command that will be the trigger for the navigation.

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>NavProject</title>
        <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
        <link href="/css/default.css" rel="stylesheet" />
        <script src="/js/homePage.js"></script>
    </head>
    <body>
         <div id="contentTarget">
                <h1>Select a page from the NavBar</h1>
        </div>
        <div id="navbar" data-win-control="WinJS.UI.AppBar" 
            data-win-options="{placement:'top'}">
    
            <button data-win-control="WinJS.UI.AppBarCommand"
                data-win-options="{id:'NextPage', label:'Next Page', 
                    icon:'\u0031', section:'selection'}">
            </button>  
        </div>
    </body>
    </html>
    

    Along with the NavBar, I have defined the div element whose id is contentTarget. This is the place in my content where the new file will be loaded when the user clicks the NavBar command.

    CLARIFICATION: All of the content that you want replaced needs to go into the contentTarget element. Otherwise you’ll get a mix of old and new content displayed.

    And here is the JavaScript file which wires it up (this is the homePage.js file which I added a script element for in the HTML file above):

    (function () {
        "use strict";
    
        WinJS.Navigation.addEventListener("navigating", function (e) {
            var elem = document.getElementById("contentTarget");
    
            WinJS.UI.Animation.exitPage(elem.children).then(function () {
                WinJS.Utilities.empty(elem);
                WinJS.UI.Pages.render(e.detail.location, elem)
                    .then(function () {
                        return WinJS.UI.Animation.enterPage(elem.children)
                    });
            });
        });
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
    
        app.onactivated = function (args) {
            args.setPromise(WinJS.UI.processAll());
    
            navbar.addEventListener("click", function (e) {
                if (e.target.id == "NextPage") {
                    WinJS.Navigation.navigate("/nextPage.html");
                }
            }, true);
    
        };
        app.start();
    })();
    

    Notice how I have added a handler function for the WinJS.Navigation.navigating event. This event is triggered by a call to WinJS.Navigation.navigate and details of the navigation target are contained in the detail.location property of the event object.

    In this example, I clear out any content in my target element and replace it with the contents of the target file and animate the transition from one to the other.

    You only have to define one handler for the event. This means that if I have elements in nextPage.html that will lead to navigation, I just need to call WinJS.Navigation.navigate without needing to create a new event handler, like this:

    <!DOCTYPE html>
    <html>
        <head>
            <title></title>
            <script>
                WinJS.UI.Pages.define("/nextPage.html", {
                    ready: function () {
                        back.addEventListener("click", function () {
                            WinJS.Navigation.navigate("/homePage.html");
                        });
                    }
                });
            </script>
        </head>
        <body>
            This is next page.
            <button id="back">Back</button>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ello, ive got the Prolog function member which tells us if an element exists
following is my code to call the database to find the substring ello. String
I have this piece of code which reads and displays input strings until a
I have a string with which i want to replace any character that isn't
I get a linker error with the following code: #include <regex> int main() {
Ello Chaps and Chapesses! I have a Javascript array like this: var tinkerArray =
I have a text file in JSON format that I downloaded using code from
Ello, I am struggling with some date troubles here in PHP/MySql. I have a
ello, I am looking for the most efficient way to do the following: Take
I need an HTML-safe function which will change a first letter of the content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.