same-origin-grand-child-iframe.html (592B)
1 <!DOCTYPE html> 2 <!-- 3 target should be fully vertically in-viewport as 100px is way less than the 4 default iframe height. 5 6 right: 0 makes sure that we're occluded by 8px by the intermediate iframe. 7 --> 8 <div id="target" style="width: 100px; height: 100px; position: absolute; right: 0"></div> 9 <script> 10 const observer = new IntersectionObserver(records => { 11 if (records[0].isIntersecting) { 12 let { rootBounds, intersectionRect } = records[0]; 13 window.top.postMessage({ rootBounds, intersectionRect }, "*"); 14 } 15 }, {}); 16 observer.observe(document.getElementById("target")); 17 </script>