Skip to content

Documentation / @frak-labs/core-sdk / index / findIframeInOpener

Function: findIframeInOpener()

findIframeInOpener(pathname?): Window | null

Defined in: utils/iframeHelper.ts:116

Find an iframe within window.opener by pathname

When a popup is opened via window.open from an iframe, window.opener points to the parent window, not the iframe itself. This utility searches through all frames in window.opener to find an iframe matching the specified pathname.

Parameters

pathname?

string = "/listener"

The pathname to search for (default: "/listener")

Returns

Window | null

The matching iframe window, or null if not found

Example

// Find the default /listener iframe
const listenerIframe = findIframeInOpener();
 
// Find a custom iframe
const customIframe = findIframeInOpener("/my-custom-iframe");