How to detect a click inside of an iframe (cross-domain)? Aka prevent click fraud

后端 未结 6 1778
萌比男神i
萌比男神i 2020-12-03 18:29

I got a warning by my ad system provider about click fraud. No further info, all they are recommending is \"hide the ads for users who click on ads too quickly\'\". I wrote

6条回答
  •  一个人的身影
    2020-12-03 19:17

    Check this it might help. You can not detect the click event when its cross browser.

    window.focus();
    window.addEventListener('blur', function(e){
      if(document.activeElement == document.getElementById('Your iframe id'))
       {
        console.log('iframe click!');
       }
    });
    

提交回复
热议问题