« Back to History
iframe_resizer.js
|
20260721_154033.php
Initial Bulk Import
Copy Code
(function () { // Only run inside iframe if (window.self === window.top) return; let lastHeight = 0; function calculateHeight() { const body = document.body; const html = document.documentElement; return Math.max( body.scrollHeight, body.offsetHeight, html.scrollHeight, html.offsetHeight, html.clientHeight ); } function sendHeight(force = false) { const h = calculateHeight(); // Never send smaller height by mistake if (!force && h <= lastHeight) return; lastHeight = h; window.parent.postMessage( { action: 'resize_erp_iframe', height: h }, window.location.origin ); } // 1️⃣ DOM ready (base layout) document.addEventListener('DOMContentLoaded', function () { requestAnimationFrame(() => sendHeight(true)); }); // 2️⃣ Full load (tables, buttons, fonts) window.addEventListener('load', function () { sendHeight(true); setTimeout(() => sendHeight(true), 150); setTimeout(() => sendHeight(true), 400); setTimeout(() => sendHeight(true), 800); }); // 3️⃣ Observe real layout changes (rows added, errors shown) const observer = new ResizeObserver(function () { sendHeight(); }); observer.observe(document.body); })();