<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <meta name="description" content="http://blog.pr1984.com - 代碼剪輯庫 ( PR 50198763 )" /> <title>符合標準的正常工作的對聯(lián)廣告</title> <script type="text/javascript"> <!-- 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("leftDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px"; document.getElementById("rightDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px"; lastScrollY=lastScrollY+percent; //alert(lastScrollY); } //下面這段刪除后,對聯(lián)將不跟隨屏幕而移動。 window.setInterval("heartBeat()",1); //--> </script> <style type="text/css"> <!-- /* 這里定義滴是頁面高度,用來測試對聯(lián)跟隨效果滴,跟廣告無關(guān) */ html,body{height:1000px;} #mm{height:1000px;} /* 這里是設(shè)置對聯(lián)樣式滴 */ #leftDiv,#rightDiv{ width:120px; /* 寬度 */ height:250px; /* 高度 */ background-color:#e5e5e5; /* 背景顏色 */ border:1px solid #ddd; /* 邊框樣式 */ position:absolute; /* 絕對定位激活 */ } --> </style> </head> <body> <div id="leftDiv" style="top:120px; left:2px;">左側(cè)廣告內(nèi)容</div> <div id="rightDiv" style="top:120px; right:2px;">右側(cè)廣告內(nèi)容</div> <div id="mm"> </div> </body> </html>