Navigation Issues RRS feed

  • Question

  • I want to Navigate from one html page to another, but I want to carry the value created by my JavaScript to the other HTML page and use it in that HTML page's javascript to render the content on the html.

    I have two js pages 1.js and 2.js and two html pages 1.html and 2.html

    I want to navigate from 1.html to 2.html, while doing so, I also want carry the value generated in 1.js to 2.js and use that value in a function to render the content to be displayed on 2.html.

    Thursday, May 16, 2013 1:39 PM


  • Hi,

    in order to pass Information from one page to another you should implement a single page Navigation approach as explained in this quickstart.

    On the bottom of the quickstart they show how to use the navigate function. You can pass a second argument to this which will be the object that you pass to the second page.

    for page1:

    // page1.js
    (function () {
        "use strict";
        WinJS.UI.Pages.define("/pages/page1/page1.html", {
                        WinJS.Utilities.query("a").listen("click", linkClickEventHandler, false); 
        function linkClickEventHandler(eventInfo) {
            var link = eventInfo.target;
            WinJS.Navigation.navigate(link.href, {value1: "your value1", value2: "your value2"});

    and in page 2

    (function () {
        "use strict";
        WinJS.UI.Pages.define("/pages/page2/page2.html", {
            ready: function (element, options) {
    // retrieve your values
                var value1 = Options.value1;
                var value2 = Options.value2;

    Thursday, May 16, 2013 3:59 PM