i looking count number of clicks iframe. need manage multiple clicks without moving mouse out of iframe.
at moment, can click 1 time iframe because blur triggered when move mouse out of iframe.
<!doctype html> <html> <head <meta charset="utf-8"> <title>count clicks iframe jquery</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> var clicks = 0; jquery(document).ready(function($){ // display active element setinterval(function(){ $('#actif').text(document.activeelement.tagname); }, 100); // initilize variable iframe_survol = false; // border checking $('.iframetrack iframe').mouseover(function(){ iframe_survol = true; }).mouseout(function(){ iframe_survol = false; }); // focus on window $(window).focus(); // blur listening , increment when click on iframe $(window).blur(function(e){ $('<div class="alert alert-info">').html("clic sur l'iframe").appendto('#consoledebug').delay(3000).fadeout(); parent.clicks += 1; document.getelementbyid("clicks").innerhtml = clicks; }); // focus on page $(document).mousemove(function(e){ if( document.activeelement.tagname == 'iframe' ){ $(window).focus(); } }); }); </script> </head> <body> <p>element actif : <span class="label" id="actif"></span></p> <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. nam cursus. morbi ut mi. nullam enim leo, egestas id, condimentum at, laoreet mattis, massa. sed eleifend nonummy diam.</p> <div class="iframetrack"> <iframe src="https://www.w3schools.com/" height="800" width="800"> </iframe> </div> <p>clicks: <a id="clicks">0</a></p> <div id="consoledebug"></div> </body> </html>
how can detect not first click iframe ? thank help.
Comments
Post a Comment