locked
Override the back button RRS feed

  • Question

  • Hi,

    I was wondering how I can override where the back button is taking me?  

    Thanks!

    Friday, April 26, 2013 1:26 PM

Answers

  • You could change the distance: WinJS.Navigation.back(distance).done( /* Your success and error handlers */ );

    Or replace it with: WinJS.Navigation.navigate(location, initialState).done( /* Your success and error handlers */ );

    Friday, April 26, 2013 4:43 PM
  • As Tinsleworm has suggested, the WinJS.Navigation namespace has provided the methods for you to manually perform navigation tasks such as going forward,  going back, or going to specific page or cancel the current navigation via certain events.

    #WinJS.Navigation Namespace
    http://msdn.microsoft.com/en-us/library/windows/apps/br229778.aspx

    So you can just put your own "back button" or other UI elements on page to control the page navigation in your windows store app.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 29, 2013 2:04 AM
    Moderator
  • Re-thinking about it idk why I didn't just think to add an ID to the back button in the HTML and do the Navigation.navigate. 

    Just added the ID in the HTML. then did 

    var back = document.getElementById("backButton");
                back.addEventListener("click", function () { goToSection("/pages/home/support.html"); }, false);

    With goToSection just being:

    function goToSection(section) {
            WinJS.Navigation.navigate(section);
        }

    • Marked as answer by ZachAtttack Friday, May 3, 2013 2:11 PM
    Friday, May 3, 2013 2:09 PM

All replies

  • You could change the distance: WinJS.Navigation.back(distance).done( /* Your success and error handlers */ );

    Or replace it with: WinJS.Navigation.navigate(location, initialState).done( /* Your success and error handlers */ );

    Friday, April 26, 2013 4:43 PM
  • As Tinsleworm has suggested, the WinJS.Navigation namespace has provided the methods for you to manually perform navigation tasks such as going forward,  going back, or going to specific page or cancel the current navigation via certain events.

    #WinJS.Navigation Namespace
    http://msdn.microsoft.com/en-us/library/windows/apps/br229778.aspx

    So you can just put your own "back button" or other UI elements on page to control the page navigation in your windows store app.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 29, 2013 2:04 AM
    Moderator
  •  

    I understand both of those, but they don't do what I'm looking for.  I'm wondering if there is a way to combine those two.

    So you put the code to have the back button change how far back it looks into the history, and the other makes a button go to a specific place. 

    I want to tell the back button to go to a specific place, still using the default back button. Something that would be along the lines of:

    WinJS.Navigation.back(location, initialState).done( /* Your success and error handlers */ );

    And be able to have that in different JS's so I can tell different pages back buttons to always go to a specific place. 

    Friday, May 3, 2013 2:01 PM
  • Re-thinking about it idk why I didn't just think to add an ID to the back button in the HTML and do the Navigation.navigate. 

    Just added the ID in the HTML. then did 

    var back = document.getElementById("backButton");
                back.addEventListener("click", function () { goToSection("/pages/home/support.html"); }, false);

    With goToSection just being:

    function goToSection(section) {
            WinJS.Navigation.navigate(section);
        }

    • Marked as answer by ZachAtttack Friday, May 3, 2013 2:11 PM
    Friday, May 3, 2013 2:09 PM