I'm doing an Ajax popup a la Netflix or Yahoo and it's working except for one issue which is when you move the pointer away from the link before the data comes back from the server my code still draws the popup box. I added some flags to my code to try and stop this and it mostly works but there are still times when the box will popup after the pointer has moved away. What I would like to be able to do is determine at the time the Ajax data comes back to the server whether or not the pointer is still over the original link and if not don't display anything. Any ideas on how I might be able to do this?
You can use a simmilar aproach than adlogger.org when detecting if mouse is over ads. So you should replace "window.addEventListener('beforeunload', doPageExit, false);" with your own event and function. /* Modified with permission from the following: Jim Rotherford's Adsense Pepper (http://www.digitalmediaminute.com), SeoBook.com for Google Analytics support (http://www.seobook.com), Dolly's Tracking Script (http://asp-net-whidbey.blogspot.com). Reference: http://www.webmasterworld.com/forum89/1788.htm Copyright 2006 AdLogger (http://www.adlogger.org) and Trevor Fitzgerald (http://www.trevorfitzgerald.com) These copyright notices must remain intact! */ /* some removed code was here */ function your_init () { if (document.all) { var el = document.getElementsByTagName("iframe"); for(var i = 0; i < el.length; i++) { if(el[i].src.indexOf('googlesyndication.com') > -1) { el[i].onfocus = ad_click; } } } else { window.addEventListener('beforeunload', doPageExit, false); window.addEventListener('mousemove', getMouse, true); } } var px; var py; function getMouse(e) { px=e.pageX; py=e.clientY; } function findY(obj) { var y = 0; while (obj) { y += obj.offsetTop; obj = obj.offsetParent; } return(y); } function findX(obj) { var x = 0; while (obj) { x += obj.offsetLeft; obj = obj.offsetParent; } return(x); } function doPageExit(e) { ad = document.getElementsByTagName("iframe"); for (i=0; i<ad.length; i++) { var adLeft = findX(ad[i]); var adTop = findY(ad[i]); var inFrameX = (px > (adLeft - 10) && px < (parseInt(adLeft) + parseInt(ad[i].width) + 15)); var inFrameY = (py > (adTop - 10) && py < (parseInt(adTop) + parseInt(ad[i].height) + 10)); if (inFrameY && inFrameX) { ad_click(); } } } Code (markup):