1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 5 <title></title> 6 <style type="text/css"> 7 <!-- 8 #lovexin12,#lovexin14{ 9 width:90px; 10 height:230px; 11 background-color:#ededed; 12 border:1px solid #ddd; 13 } 14 html,body{ 15 height:1203px; 16 } 17 #mm{ 18 height:1000px; 19 } 20 --> 21 </style> 22 23 <script language="JavaScript" type="text/javascript"> 24 lastScrollY=0; 25 function heartBeat(){ 26 var diffY; 27 if (document.documentElement && document.documentElement.scrollTop) 28 diffY = document.documentElement.scrollTop; 29 else if (document.body) 30 diffY = document.body.scrollTop 31 else 32 {} 33 percent=.1*(diffY-lastScrollY); 34 if(percent>0)percent=Math.ceil(percent); 35 else percent=Math.floor(percent); 36 document.getElementById("lovexin12").style.top=parseInt(document.getElementById 37 ("lovexin12").style.top)+percent+"px"; 38 document.getElementById("lovexin14").style.top=parseInt(document.getElementById 39 ("lovexin12").style.top)+percent+"px"; 40 lastScrollY=lastScrollY+percent; 41 } 42 suspendcode12="<DIV id="lovexin12" style='left:2px;POSITION:absolute;TOP:120px;'>ad1</div>" 43 suspendcode14="<DIV id="lovexin14" style='right:2px;POSITION:absolute;TOP:120px;'>ad2</div>" 44 document.write(suspendcode12); 45 document.write(suspendcode14); 46 window.setInterval("heartBeat()",1); 47 </script> 48 </head> 49 <body> 50 <div id="mm"></div> 51 </body> 52 </html>