securityos/node_modules/comlink/docs/examples/99-nonworker-examples/iframes/index.html

15 lines
489 B
HTML
Raw Normal View History

2024-09-06 15:32:35 +00:00
<!DOCTYPE html>
<iframe src="iframe.html"></iframe>
<script type="module">
import * as Comlink from "https://unpkg.com/comlink/dist/esm/comlink.mjs";
// import * as Comlink from "../../../../dist/esm/comlink.mjs";
async function main() {
const ifr = document.querySelector("iframe");
await new Promise((resolve) => (ifr.onload = resolve));
const f = Comlink.wrap(Comlink.windowEndpoint(ifr.contentWindow));
alert(`1 + 3 = ${await f(1, 3)}`);
}
main();
</script>