Click here to Skip to main content
15,891,136 members
Articles / Web Development / HTML5

Windows 8 JavaScript Metro Application–Getting Started

Rate me:
Please Sign up or sign in to vote.
4.98/5 (24 votes)
12 Mar 2012Ms-PL12 min read 124.6K   6.5K   74  
Getting Started with Windows 8 Metro App Development in JavaScript
(function () {
    "use strict";

    var waitFor = 10;
    var app = WinJS.Application;

    // This function responds to all application activations.
    app.onactivated = function (eventObject) {
        if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {

            // Retrieve splash screen object
            var splash = eventObject.detail.splashScreen;

            // Retrieve the window coordinates of the splash screen image.
            var coordinates = splash.imageLocation;

            // Position the extended splash screen image in the same location as the splash screen image.
            var holder = document.querySelector("#holder");

            holder.style.left = coordinates.x + "px";
            holder.style.top = coordinates.y + "px";
            holder.style.height = coordinates.height + "px";
            holder.style.width = coordinates.width + "px";

            countDown();
            setInterval(countDown, 1000);

            // Register an event handler to be executed when the splash screen has been dismissed.
            splash.addEventListener("dismissed", onSplashScreenDismissed, false);

            WinJS.UI.processAll();
        }
    };

    app.start();

    function countDown() {
        waitFor = waitFor - 1;
        if (waitFor <= 0) {
            location.href = "/html/homePage.html";
        }
        else
            document.querySelector("#timer").innerHTML = waitFor;
    }

    function onSplashScreenDismissed() {
        // Include code to be executed when the system has transitioned
        // from the splash screen to the application's first view.
    }
})();

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Architect Sela
Israel Israel
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.

My Blog: http://blogs.microsoft.co.il/blogs/shair/

Comments and Discussions