@jasen_gottlieb
To check if a dynamic element is visible inside an iframe, you can follow these steps:
- Get a reference to the iframe element using JavaScript:
1
|
var iframe = document.getElementById('myIframe');
|
- Use the contentWindow property of the iframe to get a reference to the window object inside the iframe:
1
|
var iframeWindow = iframe.contentWindow;
|
- Use the document property of the iframeWindow to access the document inside the iframe:
1
|
var iframeDocument = iframeWindow.document;
|
- Use standard DOM methods to access the dynamic element inside the iframe document:
1
|
var dynamicElement = iframeDocument.getElementById('dynamicElementId');
|
- Use the getBoundingClientRect() method of the dynamic element to check if it is visible:
1
2
|
var elementRect = dynamicElement.getBoundingClientRect();
var isVisible = (elementRect.top >= 0 && elementRect.bottom <= window.innerHeight);
|
- If isVisible is true, then the dynamic element is currently visible inside the iframe.