A lot of people in the test worker API, always can appear abnormal, don't test result.
one must be careful when using a worker, is a simple text file is not achieve the worker, you must write the actual code is deployed to the server (tomcat, jBoss, etc) to run the worker API.

to write a simple examples.
js code test js (worker)

code is as follows:

function messageHandler (e) {
postMessage (" the worker says: "+ e.d ata +" ");

} addEventListener (" message ", messageHandler, true);
postMessage (" 2222222222 ");

HTML code index. The HTML

code is as follows:

<! DOCTYPE html>
<Title> Index. Html
<Meta HTTP - equiv="keywords" content="keyword1, keyword2, keyword3 >"
<Meta HTTP - equiv="description" content="this is my page" >
<Meta HTTP - equiv="content-type" content="text/HTML; charset=utf-8" >
<! - <Link rel="stylesheet" type="text/CSS" href="http://www.jb51.net//html5/styles.css" >- >
<The script type="text/javascript" >
the if (typeof (Worker)!=="undefined") {
the console. The log (" zhichi worke ");
} else {
the console. The log (" no support!!! ");

} function messageHandler (e) {
the console. The log (e.d ata);

} function errorHandler (e) {
the console. The log (e.m essage, e);
var myWorker=new Worker (" task. Js ");
myWorker. AddEventListener (" message ", messageHandler, true);
myWorker. AddEventListener (" error ", errorHandler, true);
myWorker. PostMessage (" fangsong 1 d ");

not directly access the index. After the HTML page, and then in the browser's console panel you will see the worker send the string (general use json) transmission in actual application.
# 0 - #

This concludes the body part