locked
Equivalent of OnNavigatedTo (avaiabe in XAML/C#) in HTML/WinJS

    Question

  • Hi All,

    In Windows 8 HTLM/WinJS apps, is there any event available to detect whether the page is loading for the first time or it is navigated rfom another page...

    Scenario is :

    Let's say Page A is loaded from HomePage and from Page A ,I am navigating to Page B.

    When hitting back button in Page B, it goes to Page A. so in Page A, I need to detect whether it is from Page B and from HomePage.

    In XAML, we can use OnNavigatedFrom event to do this.

    Please let me know how to do the same in HTML/WinJS.

    Thanks in advance.

    Friday, November 01, 2013 7:34 AM

All replies

  • There is a navigated event, see details at http://msdn.microsoft.com/en-us/library/windows/apps/br229778.aspx.  However, looking at it there doesn't seem to be any data passed along the event that includes the source of the navigation, only the destination.

    An option to use would be to take advantage of the state object on the navigator and pass in the source as part of the navigate call, which you can then check in the options parameter in your page's init or ready events.

    HTH

    ~Gearard

    Friday, November 01, 2013 10:46 PM