<button onclick="sayHI()">Say HI</button> <button onclick="unknownCmd()">Send unknown command</button> <button onclick="stop()">Stop worker</button> <output id="result"></output> <script> var arr = [3, 5, 7]; arr.foo = 'hello'; for (var i in arr) { console.log(i); // logs "0", "1", "2", "foo" } for (var i of arr) { console.log(i); // logs 3, 5, 7 } function sayHI() { worker.postMessage({'cmd': 'start', 'msg': 'Hi'}); } function stop() { // worker.terminate() from this script would also stop the worker. worker.postMessage({'cmd': 'stop', 'msg': 'Bye'}); } function unknownCmd() { worker.postMessage({'cmd': 'foobard', 'msg': '???'}); } var worker = new Worker('js/webworker.js'); worker.addEventListener('message', function(e) { document.getElementById('result').textContent = e.data; }, false); </script>
Content for the first footer section.
Content for the second footer section.
Content for the third footer section.