-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mazidong
committed
May 22, 2017
1 parent
4bf127e
commit 5e42d26
Showing
5 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>webworker</title> | ||
</head> | ||
<body> | ||
<div> | ||
<button id="btnClick">Click me!</button> | ||
|
||
</div> | ||
<script src="./index.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var $ = function(_){ | ||
return document.querySelector(_); | ||
}, myWorker; | ||
|
||
if (window.Worker) { | ||
myWorker = new Worker('worker.js'); | ||
} | ||
|
||
$('btnClick').onclick = function(){ | ||
if (!myWorker) return; | ||
|
||
myWorker.postMessage(['first', 'second', 'third', 'fouth']); | ||
} | ||
|
||
myWorker.onmessage = function(e) { | ||
console.log('Receive 数据了'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
onmessage = function(e) { | ||
console.log('webwork接受到数据了', e); | ||
|
||
postMessage({a:"fasdfadf", b:"fasdfasdfasdf"}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters