JS文件
Code
//suspendcode="<DIV id=floatRight style='Z-INDEX: 10; Right: 10px; POSITION: absolute; TOP: 105px; width: 100; height: 300px;'><img src='images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭在线咨询'>客服一:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服二:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服三:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服四:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a></DIV>"
//document.write(suspendcode);
//lastScrollY=0;
//function heartBeat(){
//diffY=document.documentElement.scrollTop;
//percent=.3*(diffY-lastScrollY);
//if(percent>0)percent=Math.ceil(percent);
//else percent=Math.floor(percent);
//document.getElementById('floatRight').style.pixelTop+=percent;
//document.getElementById('floatLeft').style.pixelTop+=percent;
//lastScrollY=lastScrollY+percent;
//}
lastScrollY = 0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("floatLeft").style.top = parseInt(document.getElementById("floatLeft").style.top)+percent+"px";
document.getElementById("floatRight").style.top = parseInt(document.getElementById("floatRight").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
//下面这段删除后,对联将不跟随屏幕而移动。
function hide()
{
document.getElementById('floatRight').style.visibility="hidden";
}
function Lefthide()
{
document.getElementById('floatLeft').style.visibility="hidden";
}
window.setInterval("heartBeat()",1);
//suspendcode="<DIV id=floatRight style='Z-INDEX: 10; Right: 10px; POSITION: absolute; TOP: 105px; width: 100; height: 300px;'><img src='images/close.gif' onClick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭在线咨询'>客服一:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服二:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服三:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a><br />客服四:<a href='http://sighttp.qq.com/cgi-bin/check?sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0'; target=_blank; onclick='var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey=2caba2ff086d1d595d96fd4828dae4b23248990ae62e9885137bec3757fe01d0';var oldscript=document.getElementById('testJs');var newscript=document.createElement('script');newscript.setAttribute('type','text/javascript'); newscript.setAttribute('id', 'testJs');newscript.setAttribute('src',tempSrc);if(oldscript == null){document.body.appendChild(newscript);}else{oldscript.parentNode.replaceChild(newscript, oldscript);}return false;'><img border='0' SRC='http://wpa.qq.com/pa?p=1:185573587:3' alt='点击这里给我发消息'></a></DIV>"
//document.write(suspendcode);
//lastScrollY=0;
//function heartBeat(){
//diffY=document.documentElement.scrollTop;
//percent=.3*(diffY-lastScrollY);
//if(percent>0)percent=Math.ceil(percent);
//else percent=Math.floor(percent);
//document.getElementById('floatRight').style.pixelTop+=percent;
//document.getElementById('floatLeft').style.pixelTop+=percent;
//lastScrollY=lastScrollY+percent;
//}
lastScrollY = 0;
function heartBeat(){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById("floatLeft").style.top = parseInt(document.getElementById("floatLeft").style.top)+percent+"px";
document.getElementById("floatRight").style.top = parseInt(document.getElementById("floatRight").style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
//下面这段删除后,对联将不跟随屏幕而移动。
function hide()
{
document.getElementById('floatRight').style.visibility="hidden";
}
function Lefthide()
{
document.getElementById('floatLeft').style.visibility="hidden";
}
window.setInterval("heartBeat()",1);
其中:
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
以上代码段中对各浏览器进行判断, 确定有效的scrollTop,第一个是IE,然后对火狐最后指网景 这段代码非常关键。