How to detect a click from iframe for specific div? Alternatively, for a bit more context: Best way t

16 Replies, 1765 Views

Hey! I had the same issue trying to detect a click from iframe for specific div. Cross-origin stuff is a nightmare, but you can try using `postMessage` with a bit of extra setup.

If the iframe content is under your control, add a script inside it to send messages to the parent window when the div is clicked. Otherwise, you're kinda stuck due to security restrictions.

Check out MDN's docs on `postMessage`β€”it’s a lifesaver if you can make it work!

Messages In This Thread



Users browsing this thread: 1 Guest(s)