Unload event is not getting triggered in metro style apps


  •  WinJS.UI.Pages.define("/html/abc.html", {
            ready: ready,
            updateLayout: updateLayout,
            unload: function () {

    in the above code, when I am navigating away from the page. I want the unload function to be invoked so that I can remove the app-bar added to that page. But the problem is the unload event is not getting triggered due to which I am not able to remove the app-bar and the same app-bar is available on other pages. 
    Monday, May 21, 2012 2:53 PM


All replies

  • Dream,

    Are you using the Navigate object to track navigation?  If so it is pretty easy to listen to the onbeforenavigate event and disable what you wish in the appbar.



    Jeff Sanders (MSFT)

    Monday, May 21, 2012 3:07 PM
  • On my Win8 Consumer Preview window.unload is not firing as well.

    Is this a known issue and do we have any plans on fixing this?

    Mihail Smacinih

    Saturday, June 9, 2012 12:19 AM

  • Using the same code snippnets, the unload event is trigged when navigating away from it under Windows 8 Release Preview.

    Hope this helps. Please share with us your experience and status.


    TechNet/MSDN Forum Moderator (Unified Communications) - http://www.leedesmond.com

    Monday, July 9, 2012 4:37 PM
  • Desmond,

    Will this approach allow to "attach" to unload event in Win 8 apps but not to override the existing unload handler?

    Mihail Smacinih

    Tuesday, July 10, 2012 5:53 AM