var purl=""; var nlink=""; var ntext=""; var swidth; var tempX; var tempY; var surl="http://analytics.21cn.com/userClick"; /*跟踪所有链接的鼠标点击 * 调用方式:在需要监测的页面底部加入以下js代码:window.onload = trackLinks;或者直接调用该方法:trackLinks(); */ function trackLinks(){ var Links = document.getElementsByTagName( 'A' ); for( var i = 0; i < Links.length; i++ )    {    Links[i].onclick = trackClick; } } function trackClick(ev){ purl=document.location; nlink=this.href; ntext=this.innerHTML||this.text; ev = ev || window.event; swidth=screen.width; tempX =ev.pageX||(ev.clientX + document.documentElement.scrollLeft); tempY =ev.pageY||(ev.clientY + document.documentElement.scrollTop); tempX=tempX-(swidth-1024)/2; var image = document.createElement("img"); image.src=surl+"?purl="+escape(purl)+"&swidth="+swidth+"&x="+tempX+"&y="+tempY+"&nlink="+escape(nlink)+"&ntext="+escape(ntext); image.height = 0; image.width = 0; //send request to stat server document.body.insertBefore(image); return true; } /*仅跟踪页面链接中调用了 clickStat(obj)的点击 * 调用方式:在需要监测的链接中加入以下js代码:onclick="clickStat(this)" */ function clickStat(obj){ purl=document.location; nlink=obj.href; ntext=obj.innerHTML||obj.text; ev =window.event; swidth=screen.width; tempX =(ev.clientX + document.documentElement.scrollLeft); tempY =(ev.clientY + document.documentElement.scrollTop); tempX=tempX-(swidth-1024)/2; var image = document.createElement("img"); image.src=surl+"?purl="+escape(purl)+"&swidth="+swidth+"&x="+tempX+"&y="+tempY+"&nlink="+escape(nlink)+"&ntext="+escape(ntext); image.height = 0; image.width = 0; //send request to stat server document.body.insertBefore(image); return true; } /* 跟踪鼠标的所有点击动作 * 调用方式:在需要监测的页面加入以下js代码:document.onclick =clickStatAll */ function clickStatAll(ev){ purl=document.location; ev = ev || window.event; swidth=screen.width; tempX =ev.pageX||(ev.clientX + document.documentElement.scrollLeft); tempY =ev.pageY||(ev.clientY + document.documentElement.scrollTop); tempX=tempX-(swidth-1024)/2; var image = document.createElement("img"); image.src=surl+"?purl="+escape(purl)+"&swidth="+swidth+"&x="+tempX+"&y="+tempY+"&nlink="+escape(nlink)+"&ntext="+escape(ntext); image.height = 0; image.width = 0; //send request to stat server document.body.insertBefore(image); return true; }