javascript广告代码_两侧浮动

 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>javascript广告代码_两侧浮动</title>
 6 <style type="text/css">
 7 body { height:10000px;}
 8 </style>
 9 </head>
10 
11 <body>
12 <script>
13 var ad_LR = {    //javascript广告代码_两侧浮动
14     speed : 200,    //速度
15     ad_left_gg : "<div id=\"ad_left_gg\" style='position:absolute; z-index:10; top:5px; left:5px; width:100px; height:400px;border:1px solid #ccc;'><a href='#' onclick=\"document.getElementById('ad_left_gg').style.display='none'; return false;\">关闭</a></div>",    //左侧
16     ad_right_gg : "<div id=\"ad_right_gg\" style='position:absolute; z-index:10; top:5px; right:5px; width:100px; height:400px;border:1px solid #ccc;'><a href='#' onclick=\"document.getElementById('ad_right_gg').style.display = 'none'; return false;\">关闭</a></div>",    //右侧
17     getScroll : function getScroll(){    //根据滚动条滚动
18         var posY
19         if (document.documentElement && document.documentElement.scrollTop) {
20             posY = document.documentElement.scrollTop;
21         } else if (document.body) {
22             posY = document.body.scrollTop;
23         }
24      
25         var top=window.screen.height>900 ? 5 : 5 ; //距离top的距离
26         document.getElementById('ad_left_gg').style.top=(posY+top)+'px';
27         document.getElementById('ad_right_gg').style.top=(posY+top)+'px';
28     }
29 }
30   
31 document.write (ad_LR.ad_left_gg, ad_LR.ad_right_gg);
32 setInterval(ad_LR.getScroll, ad_LR.speed);
33     
34 </script>
35 </body>
36 </html>
posted @ 2011-08-29 16:24  dtdxrk  阅读(565)  评论(0编辑  收藏  举报