1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 16:25:07 +00:00
serenity/Base/res/html/misc/worker_parent.html

33 lines
1,021 B
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Worker</title>
</head>
<body>
<h2>Worker Test</h2>
<div id="output"></div>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
console.log("Page Loaded. Sending message");
console.log("Parent Keys: ", JSON.stringify(Object.keys(this)));
var work = new Worker("worker.js");
work.onmessage = (evt) => {
console.log("Got message from worker:", evt.data);
};
document
.getElementById("btn_hello")
.addEventListener("click", function() {
console.log("Sending Message");
work.postMessage("Hey buddy!");
});
});
</script>
<button id="btn_hello">
Say Hello!
</button>
</body>
</html>