PageSourceSearch

https://www.hetspeulderbos.nl/ui/uibase/droplets/iframe-resizer/child.js?rev=pvcv9CKYDcE

js hetspeulderbos.nl collected 2026-09-27 04:30:29 UTC 2,511 bytes, 79 lines download raw bytes

1/**
2 * @description     Communicates iframe height to parent window if said parent window
3 *                  contains iframe-resizer/parent.js
4 * @author        	Kars Kremers
5 * @copyright		Procurios - http://www.procurios.nl/
6 */
7
8;(function () {
9    // Only do something if in an iframe
10    if (window.parent !== window) {
11        window.addEventListener('load', onLoad);
12    }
13
14    function onLoad() {
15        const intervalTime = 250;
16        const maxDuration = 5000;
17
18        // Send the message multiple times in case parent isn't listening yet
19        const interval = setInterval(() => {
20            window.parent.postMessage('iframeResizerChildLoaded', '*');
21        }, intervalTime);
22
23        // Timeout after maxDuration
24        setTimeout(() => {
25            clearInterval(interval);
26        }, maxDuration);
27
28        window.addEventListener('message', (event) => {
29            if (event.data === 'iframeResizerListening') {
30                // If parent replies, stop sending and start communicating document height
31                clearInterval(interval);
32                sendIframeHeight(event.origin);
33            }
34        });
35    }
36
37    function sendIframeHeight (targetOrigin) {
38        let lastHeight = 0;
39
40        function checkHeightChange() {
41            const height = getTrueContentHeight();
42            if (height !== lastHeight) {
43                lastHeight = height;
44                window.parent.postMessage({height: height}, targetOrigin);
45            }
46        }
47
48        // 1. Observe resizes (useful for image loads, etc.)
49        const resizeObserver = new ResizeObserver(checkHeightChange);
50        resizeObserver.observe(document.body);
51        resizeObserver.observe(document.documentElement);
52
53        // 2. On user interaction
54        ['click', 'input', 'transitionend'].forEach(event =>
55            document.addEventListener(event, checkHeightChange)
56        );
57
58        // 3. Poll every 1s as a fallback (to detect shrinkage)
59        setInterval(checkHeightChange, 1000);
60
61        // 4. Initial trigger on load
62        checkHeightChange();
63    }
64
65    function getTrueContentHeight() {
66        const elements = document.body.getElementsByTagName("*");
67        let max = 0;
68
69        for (let element of elements) {
70            const rect = element.getBoundingClientRect();
71            const bottom = rect.top + rect.height;
72            if (bottom > max) {
73                max = bottom;
74            }
75        }
76
77        return Math.ceil(max + window.scrollY);
78    }
79})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.