I have the following code, trying to test out WebWorkers. I have an index.html file that looks like this:
<html> <head></head> <body> <script type='text/javascript'> var worker = new Worker('./myworker.js'); console.log('after creation'); worker.addEventListener('message', function(msg){ console.log(msg); }); worker.postMessage(); </script> </body> </html> The contents of myworker.js (which resides in the same directory as index.html) is:
this.onmessage = function(){ postMessage('got the msg, thanks'); }; When I load index.html (in Chrome 14), the 'after creation' console.log never happens. Nor anything else. Console.logs happen before the new Worker() creation, but nothing after seems to happen.