Fmdpa Posted February 19, 2011 Share Posted February 19, 2011 I'm working on a click heatmap for analyzing the activity on my website. I began by simply logging clicks using the evt.pageX/evt.pageY properties. But it wasn't long before I found out that varying screen resolutions prevent this from working accurately. How could I log the coordinates of clicks uniformly? Link to comment Share on other sites More sharing options...
Synook Posted February 20, 2011 Share Posted February 20, 2011 If your layout is fixed, then you can just use the offsetLeft of your left-most element to get the edge of your layout, then subtract that from the pageX. If it's fluid, well, then the appearance would be different for every resolution anyway. Link to comment Share on other sites More sharing options...
Fmdpa Posted February 20, 2011 Author Share Posted February 20, 2011 That's a good idea. I'll try that. Link to comment Share on other sites More sharing options...
Fmdpa Posted February 22, 2011 Author Share Posted February 22, 2011 Ok, I've got a new problem now. In my script... window.onclick = function(e) { y = e.pageY, x = e.pageX - document.getElementById('container').offsetLeft; if (x > 0 && y > 0) { //ajax stuff } } ...it only logs the clicks if they are not on links. How can make it so that when a link is clicked, the click coordinates are logged, then the new page is loaded? Link to comment Share on other sites More sharing options...
Synook Posted February 22, 2011 Share Posted February 22, 2011 Hmm... you could always bind the onclick event to the links as well with a synchronous AJAX call, this may slow things down though. Link to comment Share on other sites More sharing options...
Fmdpa Posted February 22, 2011 Author Share Posted February 22, 2011 I'll give that a try. I'm not that worried about speed very much because the data being sent is very small. Link to comment Share on other sites More sharing options...
Fmdpa Posted February 23, 2011 Author Share Posted February 23, 2011 The synchronous AJAX call worked! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.