时间:2021-07-01 10:21:17 帮助过:25人阅读
function messageHandler(e) { postMessage("worker says: " + e.data + " too"); } addEventListener("message", messageHandler, true); postMessage("2222222222");
html代码 index.html
<!DOCTYPE html> <html> <head> <title>index.html</title> <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="./styles.css">--> </head> <body> <script type="text/javascript"> if(typeof(Worker)!=="undefined"){ console.log("zhichi worke"); }else{ console.log("no support!"); } function messageHandler(e){ console.log(e.data); } function errorHandler(e){ console.log(e.message, e); } var myWorker = new Worker("task.js"); myWorker.addEventListener("message", messageHandler, true); myWorker.addEventListener("error", errorHandler, true); myWorker.postMessage("1 fangsong d"); </script> </body> </html>
以上就是html5 worker 实例(一) 为什么测试不到效果的内容,更多相关内容请关注PHP中文网(www.gxlcms.com)!