在页面加一个浮动窗口,跟随滑动而跟着走动
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <HTML>
3 <HEAD>
4 <TITLE> New Document </TITLE>
5 <META NAME="Generator" CONTENT="EditPlus">
6 <META NAME="Author" CONTENT="">
7 <META NAME="Keywords" CONTENT="">
8 <META NAME="Description" CONTENT="">
9 </HEAD>
10
11 <BODY>
12 <script>
13 function scrollImg(){
14 var posX,posY;
15 if (window.innerHeight) {
16 posX = window.pageXOffset;
17 posY = window.pageYOffset;
18 }
19 else if (document.documentElement && document.documentElement.scrollTop) {
20 posX = document.documentElement.scrollLeft;
21 posY = document.documentElement.scrollTop;
22 }
23 else if (document.body) {
24 posX = document.body.scrollLeft;
25 posY = document.body.scrollTop;
26 }
27
28 var ad=document.getElementById("ad");
29 ad.style.top=(posY+100)+"px";
30 ad.style.left=(posX+(document.body.clientWidth-250))+"px";
31 setTimeout("scrollImg()",100);
32 }
33 </script>
34
35 <div id="ad" style="position:absolute;width:201px;height:100px;border:1px dotted #000;line-height:100px;text-align:right">
36 <table width="201" height="97" border="0" bgcolor="bule">
37 <tr>
38 <td><span class='STYLE5'> 标题:</span></td>
39 </tr>
40 <tr>
41 <td><span class='STYLE5'> 标题:</span></td>
42 </tr>
43 <tr>
44 <td><span class='STYLE5'> 标题:</span></td>
45 </tr>
46 <tr>
47 <td><span class='STYLE5'> 标题:</span></td>
48 </tr>
49 </table>
50 </div>
51 <script type="text/javascript">
52 scrollImg();
53 </script>
54 </BODY>
55 </HTML>
56
posted on 2009-04-13 16:51
重庆理工小子 阅读(700)
评论(0) 编辑 收藏 所属分类:
JavaScript 、
备用代码