var cc_Stats = { exitlink: 'no exit link' }; cc_Stats.inc = function(path) { if (document.getElementsByTagName && (document.createElementNS || document.createElement)) { var tag = (document.createElementNS) ? document.createElementNS('http://www.w3.org/1999/xhtml', 'script') : document.createElement('script'); tag.type = 'text/javascript'; tag.src = path; document.getElementsByTagName('head')[0].appendChild(tag); } else if (document.write) { document.write('<' + 'script type="text/javascript" src="' + path + '"><' + '/script>'); }; }; cc_Stats.ajaxRequest = function(url) { var xmlhttp; if ( window.XMLHttpRequest ) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE5, IE6, IE7 try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP") } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } xmlhttp.open('GET', url, true); xmlhttp.send(null); }; cc_Stats.save = function(pid) { var now = new Date(); var path = 'http://www.completecounter.com/track.php'; // path = path.replace(/^https?:/, window.location.protocol); var title = document.title; var referer = (window.decodeURI)?window.decodeURI(document.referrer):document.referrer; var page = (window.decodeURI)?window.decodeURI(document.URL):document.URL; path += '?pid='+pid+'&referer='+escape(referer)+'&page='+escape(page)+'&title='+title+'&'+now.getTime(); cc_Stats.inc(path); //http://javascript.ru/forum/css-html-browser/1906-onbeforeunload.html window.onbeforeunload = function(x){ return function(e) { if (!e) var e = window.event; //alert('http://www.completecounter.com/ping-trackexitlink.php?url='+escape((window.decodeURI)?window.decodeURI(cc_Stats.exitlink):cc_Stats.exitlink)+'&'+Math.random()); cc_Stats.ajaxRequest('http://www.completecounter.com/ping-trackexitlink.php?url='+escape((window.decodeURI)?window.decodeURI(cc_Stats.exitlink):cc_Stats.exitlink)+'&'+Math.random()); if (typeof x == 'function') return x(); } }(window.onbeforeunload); for (var i=0; link = document.links[i]; i++) { link.onclick = function(x){ return function(e){ var ret = true; if (typeof x == 'function') ret = x(); if (ret != false) { var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3) // defeat Safari bug targ = targ.parentNode; cc_Stats.exitlink = targ.href; //alert('OnClick works! Sets cc_Stats.exitlink to "'+cc_Stats.exitlink+'"'); } return ret; } }(link.onclick); } }; cc_Stats.save(cc_pid); if ( cc_vis != 0 ) { document.write('Internet Hit Counter'); }