Search cross-origin frames from parent element. If the iframes are embedded from a different origin, you cannot execute any functions from your parent. This example showcases how to use postMessage
to search for a specific term across all iframes.
Ensure you are only accepting messages from the trusted event.origin
This sample only meant to work with localhost. Learn More.
cd client
npm i
cd server
npm i
cd client
npm start
cd server
npm start
Two html pages are being statically served from the server running on localhost:9000
and embedded in a client app running on localhost:8080
. You can make the search across n-iframes and listen from the search results returned by the iframes. Each iframe also highlights results.