D3F4ULT
D3F4ULT

Reputation: 934

It is possible to detect a click on an ad loaded via iframe?

Having ads loaded via iframe, it is possible to detect a click with the left mouse button? A normal click?

I thought of another question, I saw a code that worked for me but it is not secure, since it monitors the activeElement, and has a flaw in it, if the user clicks with the right mouse button, the function triggers TRUE and triggers the alert.

capture click on div surrounding an iframe

Upvotes: 0

Views: 355

Answers (1)

Menelaos
Menelaos

Reputation: 26559

If the advertisement is located on a different domain it is impossible because of security.

What you could attempt to do however, is to have a transparent element over the advertisement and detect the click there.

Then you would hide the element, and wait for the user to click a second time shrugging off the first click. If the user is actually interested in clicking the banner they will click a second time (when your transparent invisible element is gone).

Update

Have a look at this: HTML "overlay" which allows clicks to fall through to elements behind it

Apparently you can allow click through with pointer-events css.

Upvotes: 1

Related Questions