Detect Click Into iFrame using jQuery iframeTracker Plugin

File Size: 43.5 KB
Views Total: 12782
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
Detect Click Into iFrame using jQuery iframeTracker Plugin

iframeTracker is a jQuery plugin which allows for the tracking of click events on iframes embed in your webpage that can be used for many applications: tracking click event of Facebook like button, Google +1 button, Google Adsense ads and many more. In addition, this plugin allows you to manage an unlimited number of iframe, and perform different actions through callback functions.

Basic usage:

1. Include jQuery library and the jQuery iframeTracker on your webpage.

<script src="jquery.min.js"></script>
<script src="jquery.iframetracker.js"></script>

2. Call the plugin on the iframe element and execute a callback once the visitor click on the iframe.

$('iframe').iframeTracker({
  blurCallback: function(){
      // Do something
  }
});

3. More callback functions.

$('iframe').iframeTracker({
  blurCallback: function(){
      // Do something
  },

  overCallback: function(element){
      // Saving the iframe wrapper id
      this._overId = $(element).parents('.iframe_wrap').attr('id'); 
  },
  outCallback: function(element){

      // Reset hover iframe wrapper id
      this._overId = null; 
  },

   _overId: null
});

4. Methods.

// initialize the plugin
$.iframeTracker()

// untrack a specified iframe
$.iframeTracker(false);

Change log:

2018-03-27

  • v2.1.0

This awesome jQuery plugin is developed by vincepare. For more Advanced Usages, please check the demo page or visit the official website.