Home  >  Article  >  Web Front-end  >  html5 worker example (1) Why the test fails to work

html5 worker example (1) Why the test fails to work

黄舟
黄舟Original
2016-12-20 14:57:431417browse

Many people always encounter exceptions when testing the worker API and cannot test the effect at all.
One thing you must pay attention to when using workers is that a simple text file cannot implement a worker. The actual code you write must be deployed to the server (tomcat.jBoss, etc.) to run the worker api.
Write a simple example below

js code test.js (worker)

function messageHandler(e) { 
postMessage("worker says: " + e.data + " too"); 
} 
addEventListener("message", messageHandler, true); 
postMessage("2222222222");

html code index.html

 
 
 
index.html 
 
 
 
 

The above is the html5 worker example (1) why the test cannot be effective, please pay attention to more related content PHP Chinese website (m.sbmmt.com)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn