Catch/Intercept all mouse clicks
Posted
by Hallik
on Stack Overflow
See other posts from Stack Overflow
or by Hallik
Published on 2010-06-16T20:19:01Z
Indexed on
2010/06/16
20:22 UTC
Read the original article
Hit count: 168
jQuery
|jquery-ajax
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":evt.pageX,
"y":evt.pageY,
"click":"true",
"w":width,
"h":height,
"l":escape(document.location.pathname),
"d":escape(document.domain)
});
});
};
})(jQuery);
$(function() {
$(document).saveClicks();
});
© Stack Overflow or respective owner