私はHTML5を初めて使用します。私は最近HTML5の基本を学びましたが、HTML5を使用したコーディングの中間レベルに進むと、「HTML5Webワーカー」というものを思いつきました。私はそれを使って簡単なプログラムを書きましたが、動作しません。
私のHTML5コード:
<html>
    <head>
        <title>HTML5 - Web Workers</title>
    </head>
    <body>
        <p>Count : <output id="result"></output></p>
        <button onclick="startWorker()">Start count</button>
        <button onclick="endWorker()">End count</button>
        <script>
        var w; //the variable of object for web worker
        function startWorker() {
            if(typeof(Worker)!="undefined") //checking if browser supports web worker
            {
                if(typeof(w)=="undefined")
                {
                    w = new Worker("counter.js");
                }
                w.onmessage = function(e)
                {
                    document.getElementById('result').innerHTML = e.data;
                };
            }
            else
            {
                document.getElementById('result').innerHTML = "Your browser doesnot support HTML5 Web Worker! :)"; // or display the message that web worker is not supported!
            }
        }
        function endWorker() {
            w.terminate();
        }
        </script>
    </body>
</html>
私のWebワーカーファイル:
var i=0;
function timedCount() {
    i=i+1;
    postMessage(i);
    setTimeout("timedCount()", 500);
}
timedCount();
なぜ機能しないのか教えていただけますか?