-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (25 loc) · 913 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var workerFor = new Worker('../workers/for.js');
/*
workerFor.addEventListener('message', function(event) {
console.log('message received from workerFor => ', event.data);
var div = document.getElementById('result');
div.innerHTML = 'message received from workerFor => ' +event.data;
});
workerFor.addEventListener('error', function(event) {
console.error('error received from workerFor => ', event);
});
*/
workerFor.onmessage = function(event) {
var div = document.getElementById('result');
div.innerHTML = 'message received from workerFor => ' +event.data;
};
workerFor.onerror = function(event) {
console.error('error received from workerFor => ', event);
var div = document.getElementById('result');
div.innerHTML = 'Error!';
};
function loadResult(){
var div = document.getElementById('result');
div.innerHTML = 'loading...';
workerFor.postMessage(null);
};