我做的一个类似小广告的小窗口,我想让他实现自动向下滚动,请问如何实现呢?
---------------------------------------------------------------
将下面的代码复制到
1<body>内
2
3
4<div id="point1" style="position:absolute;visibility:visible;">
5<!--Please delete this table and insert into your html elements-->
6<table border="0" cellpadding="0" cellspacing="0">
7<tr>
8<td>
9<a href="../../../www.dynamicdrive.com/index.html">
10<img alt="" border="0" height="60" src="../ddaward.gif" width="96"/>
11</a>
12</td>
13</tr>
14<tr>
15<td>
16<center><a href="../../../www.dynamicdrive.com/index.html">
17<font color="#0000FF" face="Arial" size="2">Dynamic Drive</font>
18</a></center>
19</td>
20</tr>
21<tr>
22<td>
23<center><a href="../../../www.dynamicdrive.com/new.htm">
24<font color="#0000FF" face="Arial" size="2">What's New</font>
25</a></center>
26</td>
27</tr>
28</table>
29<!--End of the customizable area, please do not delete div the tag -->
30</div>
31<script language="JavaScript1.2">
32
33/*
34Floating image II (up down)- Bruce Anderson (http://appletlib.tripod.com)
35Submitted to Dynamicdrive.com to feature script in archive
36Modified by DD for script to function in NS6
37For 100's of FREE DHTML scripts, Visit http://www.dynamicdrive.com
38*/
39
40var XX=20; // X position of the scrolling objects
41var xstep=1;
42var delay_time=60;
43
44//Begin of the unchangable area, please do not modify this area
45var YY=0;
46var ch=0;
47var oh=0;
48var yon=0;
49
50var ns4=document.layers?1:0
51var ie=document.all?1:0
52var ns6=document.getElementById&&!document.all?1:0
53
54if(ie){
55YY=document.body.clientHeight;
56point1.style.top=YY;
57}
58else if (ns4){
59YY=window.innerHeight;
60document.point1.pageY=YY;
61document.point1.visibility="hidden";
62}
63else if (ns6){
64YY=window.innerHeight
65document.getElementById('point1').style.top=YY
66}
67
68
69function reloc1()
70{
71
72if(yon==0){YY=YY-xstep;}
73else{YY=YY+xstep;}
74if (ie){
75ch=document.body.clientHeight;
76oh=point1.offsetHeight;
77}
78else if (ns4){
79ch=window.innerHeight;
80oh=document.point1.clip.height;
81}
82else if (ns6){
83ch=window.innerHeight
84oh=document.getElementById("point1").offsetHeight
85}
86
87if(YY<0){yon=1;YY=0;}
88if(YY>=(ch-oh)){yon=0;YY=(ch-oh);}
89if(ie){
90point1.style.left=XX;
91point1.style.top=YY+document.body.scrollTop;
92}
93else if (ns4){
94document.point1.pageX=XX;
95document.point1.pageY=YY+window.pageYOffset;
96}
97else if (ns6){
98document.getElementById("point1").style.left=XX
99document.getElementById("point1").style.top=YY+window.pageYOffset
100}
101
102}
103
104function onad()
105{
106if(ns4)
107document.point1.visibility="visible";
108loopfunc();
109}
110function loopfunc()
111{
112reloc1();
113setTimeout('loopfunc()',delay_time);
114}
115
116if (ie ¦ ¦ns4 ¦ ¦ns6)
117window.onload=onad
118
119</script>
120
121
122\---------------------------------------------------------------
123
124http://www.8u8.com/book/js/991110.htm
125\---------------------------------------------------------------
126
127原代码如下,把它放在html的<head></head>之间。
128
129<script language="JavaScript">
130<!--
131locate = 0;
132function scroller() {
133if (locate !=500 ) {
134locate++;
135scroll(0,locate);
136clearTimeout(timer);
137var timer = setTimeout("scroller()",3);
138timer;
139}
140}
141// -->
142</script>
143
144修改<body>语句为:
145
146<body onload="scroller()">
147
148可通过改动locate的数值来控制显示页面的长度(原代码中为locate!=600)。将“setTimeout("scroller()",3);”中的“3”改为其它的数字可控制速度。
149
150\---------------------------------------------------------------
151
152<script language="JavaScript">
153<!--
154locate = 0;
155function scroller() {
156if (locate !=600 ) {
157locate++;
158scroll(0,locate);
159clearTimeout(timer);
160var timer = setTimeout("scroller()",3);
161timer;
162}
163else{locate=0
164scroll(0,locate);
165clearTimeout(timer);
166var timer = setTimeout("scroller()",3);
167timer;
168}
169}
170// -->
171</script>
172
173修改<body>语句为:
174<body onload="scroller()">
175
176要注意的是:上面代码中locate的值应该根据你所制作的页面的高度适当调整。
177\---------------------------------------------------------------
178
179你们都说完了,
180我来不及了,楼主,给我几分也。</body></body></body></body></body>