//this script should be incluced as early as possible in the head section of a page var URL_Q = 'http://qstats.q42.nl/'; var url_q = ''; var d_q = new Date(); var dt1_q = -1; var dt2_q = -1; var href_q = ''; var inview_q = 0; var toh_q = null; var hasBeenPrinted = 0; //see if IE if (window.attachEvent) { //start an interval to look for the body toh_q = setInterval(checkBody_q, 10); } function checkBody_q() { if (document && document.body) { //body has been found: clear interval clearInterval(toh_q); //see if document already loaded if (document.readyState == 'complete') doLoad_q(); else window.attachEvent('onload', doLoad_q); //attach onbeforeunload window.attachEvent('onbeforeunload', doBeforeUnload_q); //attach onmousedown document.body.attachEvent('onmousedown', function() { //get element clicked var el = event.srcElement; //search for href attribute while (el && !el.href) el = el.parentNode; //store href clicked if (el) href_q = el.href; if (event.altKey && (event.clientX < 10) && (event.clientY < 10)) { document.body.appendChild(document.createElement('')); } }); //attach onscroll window.attachEvent('onscroll', doScroll_q); //attach onscroll window.attachEvent('onbeforeprint', function(){hasBeenPrinted=1;}); } } function doLoad_q() { //note loaded time dt1_q = Math.floor((+new Date() - d_q)/1000); //call scroll once doScroll_q(); url_q = document.location.href + '#'; url_q = url_q.substring(0, url_q.indexOf('#')); } function doBeforeUnload_q() { //see if we need to count if (typeof(DONTCOUNT_Q) != 'undefined') return; //construct string containing all data var db = document.body; var s = '' //get t0: start time +'t0='+1*d_q //dt1: time to window loaded +'&dt1='+dt1_q //dt2: time to window unloading +'&dt2='+Math.floor((+new Date() - d_q)/4000) //tzo: time-zone-offset +'&tzo='+d_q.getTimezoneOffset()/60 //url: current url +'&url='+escape(url_q) //ref: referrer +'&ref='+escape(document.referrer) //href: href clicked +'&href='+escape(href_q) //cd: colorDepth +'&cd='+screen.colorDepth //sw: screenWidth +'&sw='+screen.width //sh: screenHeight +'&sh='+screen.height //ww: window width +'&ww='+db.clientWidth //wh: window height +'&wh='+db.clientHeight //part of page that was in view during visit +'&iv='+inview_q //ul: userLanguage +'&ul='+navigator.userLanguage //os: operating system +'&os='+navigator.platform //p: printed +'&p='+hasBeenPrinted //nav: navigator.appVersion +'&nav='+escape(navigator.appVersion); //alert(URL_Q + 'qstats.asp?' + s); //send info by creating a script tag db.appendChild(document.createElement('')); //debug if (document.location.href.indexOf('?lon=') != -1) { var w = window.open(); w.document.open(); w.document.write(unescape(URL_Q + 'qstats.asp?' + s)); w.document.close(); window.open(URL_Q + 'qstats.asp?' + s); } } function doScroll_q() { var db = document.body; //get relative position of scroll bar var relScroll = Math.floor(100*(db.scrollTop + db.offsetHeight)/db.scrollHeight); //store highest inview_q = Math.max(inview_q, relScroll); }