diff options
Diffstat (limited to '05_callback/script.mjs')
| -rw-r--r-- | 05_callback/script.mjs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/05_callback/script.mjs b/05_callback/script.mjs new file mode 100644 index 0000000..9fce6fe --- /dev/null +++ b/05_callback/script.mjs | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | var aInput = document.getElementById("aInput"); | ||
| 2 | var bInput = document.getElementById("bInput"); | ||
| 3 | var button = document.getElementById("goButton"); | ||
| 4 | var resultText = document.getElementById("resultText"); | ||
| 5 | |||
| 6 | var worker = new Worker("./worker.mjs", { type: "module" }); | ||
| 7 | |||
| 8 | button.addEventListener("click", () => worker.postMessage({ | ||
| 9 | a: Number(aInput.value), | ||
| 10 | b: Number(bInput.value) | ||
| 11 | })); | ||
| 12 | |||
| 13 | worker.onmessage = (e) => resultText.innerText = e.data.message; | ||
