summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorJoel Stålnacke <joel@saker.fi>2026-03-19 11:39:15 +0200
committerJoel Stålnacke <joel@saker.fi>2026-03-19 11:39:49 +0200
commita22dfee999685cdfd4d9b20c74d0a41105de45e1 (patch)
treea13ac4274ded0c05f4a1df0438598541742c8d99 /demo
Add demoHEADmain
Diffstat (limited to 'demo')
-rw-r--r--demo/main.html40
-rw-r--r--demo/page.html21
2 files changed, 61 insertions, 0 deletions
diff --git a/demo/main.html b/demo/main.html
new file mode 100644
index 0000000..47f2c7a
--- /dev/null
+++ b/demo/main.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <title>Document viewer</title>
+ <style>
+ .viewer {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ margin: 0 auto;
+ max-width: 60rem;
+ }
+
+ .viewer_frame {
+ width: 100%;
+ }
+ </style>
+</head>
+
+<body>
+ <main>
+ <h1>
+ Document viewer
+ </h1>
+ <button id="print-button">Print</button>
+ <section class="viewer">
+ <iframe id="frame" class="viewer_frame" src="page.html"></iframe>
+ </section>
+ </main>
+ <script>
+ document.getElementById("print-button").onclick = (e) => {
+ let frame = document.getElementById("frame");
+ frame.contentWindow.postMessage("print", "*");
+ };
+ </script>
+</body>
+
+</html>
diff --git a/demo/page.html b/demo/page.html
new file mode 100644
index 0000000..5d16c82
--- /dev/null
+++ b/demo/page.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <script>
+ window.addEventListener("message", (e) => {
+ if (e.data === "print") {
+ window.print();
+ }
+ });
+ </script>
+</head>
+
+<body>
+ <main>
+ <h1>Hello World</h1>
+ <p>This is an example document</p>
+ </main>
+</body>
+
+</html>