Solution 1 :

The things that we can do with iframes is that, we can manipulate things on the site in which iframe is used with Javascript’s contentWindow and contentDocument. Try these and see if they could help.

The contentWindow property returns the Window object of an
HTMLIFrameElement. You can use this Window object to access the
iframe’s document and its internal DOM. This attribute is read-only,
but its properties can be manipulated like the global Window object.

Using jQuery:

Use the jQuery contents() method

If you try to detect or capture a click event inside an iframe simply using jQuery click() method it will not work, because iframe embed a web page within another web page. However, you can still do it on the same domain utilizing the jQuery contents() and load() method.

Try this resource:

Problem :

I’m trying to detect click on third-party iFrame which loaded and rendered on another server.

I’m add click listener on my parent div, which contain iframe. But its listener working only if i click on div, not on iframe inside this div.

Is any way to detect click on iframe inside my div? Maybe is some ReactJS libs for this?


Comment posted by epascarello

nope……….. If you search here, I am sure you will get answers that use blur to try to guess they are in the iframe…

Comment posted by CBroe

You can not detect clicks inside the iframe. At most you could detect clicks on a transparent element of

Comment posted by Nataly Firstova

CBroe I don’t want to track clicks inside iframe. I have advertising code, which generate iframe with banner inside “my” div. I want to track and count people, who clicks on it.

Comment posted by Atlante Avila

Are you in control of both the contents? Meaning is the iframe a web app that you developed?

Comment posted by Nataly Firstova

No, only div container,