0

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

Community
  • 1
  • 1
D3F4ULT
  • 926
  • 1
  • 12
  • 20

1 Answers1

1

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.

Community
  • 1
  • 1
Menelaos
  • 23,508
  • 18
  • 90
  • 155
  • I got to see a site using, but at the time I forgot to save the link it, it worked perfectly, used this same technique to create a transparent div. – D3F4ULT Jun 19 '13 at 21:24
  • Well, seems there is a workaround that I just posted. They even discuss a workaround for IE... you can have your click detection overlay and have the click go down :) – Menelaos Jun 19 '13 at 21:26