nested-iframe.html (979B)
1 <!DOCTYPE html> 2 3 <style> 4 body { 5 --top-scale: 1; 6 --sub-scale: 1; 7 margin: calc(12px * var(--top-scale)); 8 background-color: orange; 9 } 10 iframe { 11 border: none; 12 width: calc(96px * var(--top-scale) * var(--sub-scale)); 13 height: calc(48px * var(--top-scale) * var(--sub-scale)); 14 } 15 </style> 16 17 <iframe id="target" scrolling="no"></iframe> 18 19 <script> 20 let target = document.getElementById("target"); 21 let params = new URLSearchParams(location.search); 22 let scale = 1; 23 24 if (params.has("zoom")) { 25 target.style.zoom = parseFloat(params.get("zoom")); 26 } 27 if (params.has("topscale")) { 28 let topscale = parseFloat(params.get("topscale")); 29 document.body.style.setProperty("--top-scale", topscale); 30 scale *= topscale; 31 } 32 if (params.has("subscale")) { 33 let subscale = parseFloat(params.get("subscale")); 34 document.body.style.setProperty("--sub-scale", subscale); 35 scale *= subscale; 36 } 37 38 let url = "leaf.html"; 39 if (scale != 1) { 40 url += `?scale=${scale}`; 41 } 42 target.src = url; 43 </script>