detect click inside iframe

前端 未结 5 1711
被撕碎了的回忆
被撕碎了的回忆 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:43

    Try this

    $(window).click( function(e){
        $('#result').text('Clicked inside document');
    });
    
    $(window).blur( function(e){
        $('#result').text('Clicked out of the window or on the iframe');
    });​
    

    test http://jsfiddle.net/4vBRe/

    To detect only the click on iframe then use mouseover event then blur

提交回复
热议问题