HTML and CSS Reference
In-Depth Information
Close the browser and stop the debugger.
in the Solution Explorer, right-click the Scripts folder and select the Add
➤ new item
links. in the Add new item dialog box, select the Web category and then select the
JavaScript File item. Enter worker.js for the filename as shown in Figure 5-6 .
Figure 5-6. Adding the worker.js file
Tip You can also right-click the Scripts folder and select the Add ➤ JavaScript File links, which will skip the Add
new item dialog box. When prompted for the file name, leave the .js extension off, however.
For the contents of this file, enter the following code. This is the implementation
of the worker. it handles both the onconnect event (when the worker is first
created) and the onmessage event (when a message is sent to the worker). The
implementation simply echoes the message back to the caller.
/* This file implements the web worker */
onconnect=sendResponse("The worker has started");
onmessage=function (event) {
sendResponse("Msg received: " +;
function sendResponse(message) {
Using the same instructions, add a
controlWorker.js file in the Scripts folder.
Search WWH ::

Custom Search