sendStatement = function(data){ var url = apphome + "/tincan/sendstatement.html"; $.get(url,data); } jQuery(window).on("beforeunload", function(){ }); var start = Date.now(); var delta; setInterval(function() { delta = Date.now() - start; // milliseconds elapsed since start // alternatively just show wall clock time: }, 1000); // update about every second