Jan 27

If you’ve been doing Web development from some time now and you’ve looked at several of the Windows 8 samples, you’re probably wondering which event you should handle if you’re interested in doing work as soon as you can. The first option you have is to handle the DOMContentLoaded event. As you probably know, this event will be fired when the current document has been parsed (but might not have been totally loaded – ex.: images might still being downloaded, but you can interact with all the DOM elements).

Since you’re writing a Windows 8 application, them you should also know that the WinJS library will handle this event. Internally, the library does some housekeeping, which lead to the generation of several WinJS custom events. Currently, you’ll end up with the following sequence of events: loaded (fired right after the DOMContentLoaded event), mainwindowactivated (similar to activated; in fact, it’s generated from the internal WinJS activated event handler), activated (occurs after WinRT activation has occurred), ready (occurs when the application is ready and all the housekeeping has been done).

Since we’re talking about events, then  don’t forget that you must always call the WinJS.Application.start method or you won’t get any of the WinJS events. This happens because, under the hood,  WinJS queues events and it will only start processing them after you call that method.

And that’s it for now. Stay tuned for more.

1 comment so far

  1. Adam Weber
    9:28 pm - 8-2-2012

    Oh, Microsoft is so confused. They need to stop trying to make a “better” OS, and just make a Smarter OS. Windows 7 does a decent job, but not for the fancy Aero effects or shiny orbs, but because it automatically searches for hardware drivers, and does a better job of diagnosing problems. I would be happy if Microsoft focused all their energy on Driver functionality, integration with Skydrive or other iCloud clone right out of the box, and overall just better support for functions. We don’t need another interface to learn, or something that takes away power from the user. I like making custom toolbars, and arranging windows however I see fit, or changing sound options, the list goes on. Microsoft needs to stop trying to imitate Apple and focus on what Apple cant do – create a dynamic and powerful OS that works well on various hardware platforms. M$ is going to dig their own grave by trying to imitate Apple!