1 <script language="javascript">
2 function close_float_left(){
3 AdLayer1.style.visibility="hidden";
4 }
5 function close_float_right(){
6 AdLayer2.style.visibility="hidden";
7 }
8 </script>
9 <SCRIPT LANGUAGE="JavaScript">
10 <!--
11 //more javascript from http://www.smallrain.net
12 function initEcAd() {
13 document.all.AdLayer1.style.posTop =130;
14 document.all.AdLayer1.style.visibility = 'visible'
15 document.all.AdLayer2.style.posTop =130;
16 document.all.AdLayer2.style.visibility = 'visible'
17 MoveLeftLayer('AdLayer1');
18 MoveRightLayer('AdLayer2');
19 }
20 function MoveLeftLayer(layerName) {
21 var x = 5;
22 var y = 130;
23 var diff = (document.body.scrollTop + y - document.all.AdLayer1.style.posTop)*.40;
24 var y = document.body.scrollTop + y - diff;
25 eval("document.all." + layerName + ".style.posTop = parseInt(y)");
26 eval("document.all." + layerName + ".style.posLeft = x");
27 setTimeout("MoveLeftLayer('AdLayer1');", 20);
28 }
29 function MoveRightLayer(layerName) {
30 var x = 5;
31 var y = 130;
32 var diff = (document.body.scrollTop + y - document.all.AdLayer2.style.posTop)*.40;
33 var y = document.body.scrollTop + y - diff;
34 eval("document.all." + layerName + ".style.posTop = y");
35 eval("document.all." + layerName + ".style.posRight = x");
36 setTimeout("MoveRightLayer('AdLayer2');", 20);
37 }
38
39 document.write("<div id='AdLayer1' style='position:absolute; width:100px; height:300px; z-index:1; left: 7px; top: 165px; visibility:visible'><table align='center' width='100%' border=0 cellspacing=1 cellpadding=2><tr><td height='284'>"
40 +"<a href='ad/gqyl.htm' target='_blank'><img src='ad/gqdx.jpg' width='102' height='300' border=0></a></td></tr><tr><td height='16'>"
41 +"<div align='center'><a href='javascript:close_float_left();'>關閉</a></div></td></tr></table></div>"
42 +"<div id='AdLayer2' style='position:absolute; width:100px; height:300px; z-index:1; right: 7px; top: 165px; visibility:visible'><table align=center width='100%' border=0 cellspacing=1 cellpadding=2><tr><td height='284'>"
43 +"<a href='newspaper/index.aspx' target='_blank'><img border=0 src='ad/DG.jpg'></a></td></tr><tr><td height='16'>"
44 +"<div align='center'><a href='javascript:close_float_right();'>關閉</a></div></td></tr></table></div>");
45 initEcAd()
46 //-->
47 </SCRIPT>
裡面AdLayer1就是左邊的,AdLayer2就是右邊的。這個其實就是移動捲軸後在新的位置畫出document後的東西。
至於頁面浮動廣告可以通過時間軸來實現,弄幾個關鍵針,就象flash一樣,然後它就自己開始動了。