detect click inside iframe

前端 未结 5 1694
被撕碎了的回忆
被撕碎了的回忆 2020-12-18 06:02

i wanna detect click INSIDE iframe not onclick on iframe itself i tried onclick event u must click on iframe itself to trigger function i even tried addeventlistener to wind

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-18 06:32

    Only works on iframes on the same domain:

    $('body', $('select-your-iframe-here').contents()).click(function(event) {
      console.log('Clicked! ' + event.pageX + ' - ' + event.pageY);
    });
    

提交回复
热议问题