From e5808ed1893631ede0454d51d1c63a5d9f58b5eb Mon Sep 17 00:00:00 2001 From: Jacob Williams Date: Fri, 18 Jan 2013 15:13:52 -0600 Subject: [PATCH] Update js/clickheat-original.js --- js/clickheat-original.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/clickheat-original.js b/js/clickheat-original.js index 70c8d8e..b61a849 100644 --- a/js/clickheat-original.js +++ b/js/clickheat-original.js @@ -223,10 +223,15 @@ function catchClickHeat(e) /** Little waiting cycle: default is to wait until Ajax sent or until the end of the time if no Ajax is available */ now = new Date(); clickHeatLocalWait = now.getTime() + clickHeatWait; - while (clickHeatLocalWait > now.getTime()) - { - now = new Date(); - } + /* by adding the wait cycle to the onbeforeunload event, it will not run until the + page navigates away. This will prevent delays on clicks that do not cause navigation + such as form elements. */ + addEvtListener(window, 'onbeforeunload', function() { + while (clickHeatLocalWait > now.getTime()) + { + now = new Date(); + } + }); } catch (err) { @@ -296,4 +301,4 @@ function initClickHeat() } } showClickHeatDebug('ClickHeat initialised with:
site = ' + clickHeatSite + '
group = ' + clickHeatGroup + '
server = ' + clickHeatServer + '
quota = ' + (clickHeatQuota === -1 ? 'unlimited' : clickHeatQuota) + '

browser = ' + clickHeatBrowser + '
Click in a blank area (not on a link) to test ClickHeat'); -} \ No newline at end of file +}