I have this simple script that catches all mouse clicks, unless you click on something that actually works. Links, flash videos, etc. How can I adjust this so no matter what a user clicks on, before the video loads, new page loads, etc. It sends the simple GET request I built?
(function($) {
$.fn.saveClicks = function() {
$(this).bind('mousedown.clickmap', function(evt) {
var clickDocument = (document.documentElement != undefined && document.documentElement.clientHeight != 0) ? document.documentElement : document.body;
var width = clickHeatDocument.clientWidth != undefined ? clickDocument.clientWidth : window.innerWidth;
var height = clickHeatDocument.clientHeight != undefined ? clickDocument.clientHeight : window.innerHeight;
var scrollx = window.pageXOffset == undefined ? clickDocument.scrollLeft : window.pageXOffset;
var scrolly = window.pageYOffset == undefined ? clickDocument.scrollTop : window.pageYOffset;
var x = evt.clientX + scrollx;
var y = evt.clientY + scrolly;
$.get('/click-save.php', {
"x":x,
"y":y,
"click":"true",
"w":width,
"h":height,
"l":escape(document.location.pathname),
"d":escape(document.domain)
});
});
};
})(jQuery);
$(function() {
$(document).saveClicks();
});