Skip to content

Observing iframe events in insights script - #822

Open
Muhammad AlAref (malaref) wants to merge 1 commit into
masterfrom
malaref/insights-iframe-events
Open

Observing iframe events in insights script#822
Muhammad AlAref (malaref) wants to merge 1 commit into
masterfrom
malaref/insights-iframe-events

Conversation

@malaref

Copy link
Copy Markdown
Contributor

No description provided.

const iframes = document.querySelectorAll("iframe");
for (let i = 0; i < iframes.length; i++) {
const iframe = iframes[i];
if (iframe.contentDocument) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can throw exception if iframe is cross origin so better to wrap it in try catch to avoid console errors

@nairmanu
nairmanu self-requested a review April 30, 2025 23:57
for (let i = 0; i < iframes.length; i++) {
const iframe = iframes[i];
if (iframe.contentDocument) {
getId(iframe.contentDocument.documentElement); // Pre-discover ID for iframe root

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to call getId?

@nairmanu nairmanu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls check for potential errors esp in safari when accessing iframe.contentDocument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants