怎么实现在网页中添加滚动条啊?

我这里有个网站www.rggg.cn/mewlw,我想把左边网站公告一栏中的标题做成能向上循环滚动的效果,哪位老大可以较较小弟啊不胜感谢!!!... 我这里有个网站www.rggg.cn/mewlw ,我想把左边网站公告一栏中的标题做成能向上循环滚动的效果,哪位老大可以较较小弟啊
不胜感谢!!!
展开
 我来答
临载娟7299
2006-11-30 · 超过51用户采纳过TA的回答
知道答主
回答量:140
采纳率:100%
帮助的人:143万
展开全部
要完成此效果需要两个步骤

第一步:把如下代码加入到<head>区域中

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function verScroll(dir, spd, loop) {
loop = true;
direction = "up";
speed = 10;
scrolltimer = null;
if (document.layers) {
var page = eval(document.contentLayer);
}
else {
if (document.getElementById) {
var page= eval("document.getElementById( contentLayer ).style");
}
else {
if (document.all) {
var page = eval(document.all.contentLayer.style);
}
}
}
direction = dir;
speed = parseInt(spd);
var y_pos = parseInt(page.top);
if (loop == true) {
if (direction == "dn") {
page.top = (y_pos - (speed));
} else {
if (direction == "up" && y_pos < 10) {
page.top = (y_pos + (speed));
} else {
if (direction == "top") {
page.top = 10;
}
}
}
scrolltimer = setTimeout("verScroll(direction,speed)", 1);
}
}
function stopScroll() {
loop = false;
clearTimeout(scrolltimer);
}
// End -->
</script>

第二步:把如下代码加入到<body>区域中

<div id="contentLayer" style="position:absolute; width:300px; z-index:1; left: 39px; top: 51px">

aaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc
ddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeee
rrrrrrrrrrrrrrrrrrrrrrrr
ffffffffffffffffffffffg
ggggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhe
eeeeeeeeeeeeeeeeeeeeeee

</div>
<div id="scrollmenu" style="position:absolute;width:236px;height:30px;z-index:1; left:328px; top: 44px">
<table border=1><tr><td>
<table>
<tr>
<td align=left>Up</td>
<td> </td>
<td align=right>Down</td>
</tr>
<tr>
<td colspan=3>
<a href="#" onMouseOver="verScroll( up , 25 , true )" onMouseOut="stopScroll()"><<<</a>
<a href="#" onMouseOver="verScroll( up , 5 , true )" onMouseOut="stopScroll()"><<</a>
<a href="#" onMouseOver="verScroll( up , 1 , true )" onMouseOut="stopScroll()"><</a> |
<a href="#" onMouseOver="verScroll( dn , 1 , true )" onMouseOut="stopScroll()">></a>
<a href="#" onMouseOver="verScroll( dn , 5 , true )" onMouseOut="stopScroll()">>></a>
<a href="#" onMouseOver="verScroll( dn , 25 , true )" onMouseOut="stopScroll()">>>></a>
</td>
</tr>
</table>
</td></tr></table>
</div>
百度网友a40d1aec0bf
2019-08-01 · TA获得超过3698个赞
知道大有可为答主
回答量:3045
采纳率:32%
帮助的人:195万
展开全部
要完成此效果需要两个步骤
第一步:把如下代码加入到<head>区域中
<SCRIPT
LANGUAGE="JavaScript">
<!--
Begin
function
verScroll(dir,
spd,
loop)
{
loop
=
true;
direction
=
"up";
speed
=
10;
scrolltimer
=
null;
if
(document.layers)
{
var
page
=
eval(document.contentLayer);
}
else
{
if
(document.getElementById)
{
var
page=
eval("document.getElementById(
contentLayer
).style");
}
else
{
if
(document.all)
{
var
page
=
eval(document.all.contentLayer.style);
}
}
}
direction
=
dir;
speed
=
parseInt(spd);
var
y_pos
=
parseInt(page.top);
if
(loop
==
true)
{
if
(direction
==
"dn")
{
page.top
=
(y_pos
-
(speed));
}
else
{
if
(direction
==
"up"
&&
y_pos
<
10)
{
page.top
=
(y_pos
+
(speed));
}
else
{
if
(direction
==
"top")
{
page.top
=
10;
}
}
}
scrolltimer
=
setTimeout("verScroll(direction,speed)",
1);
}
}
function
stopScroll()
{
loop
=
false;
clearTimeout(scrolltimer);
}
//
End
-->
</script>
第二步:把如下代码加入到<body>区域中
<div
id="contentLayer"
style="position:absolute;
width:300px;
z-index:1;
left:
39px;
top:
51px">
aaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc
ddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeee
rrrrrrrrrrrrrrrrrrrrrrrr
ffffffffffffffffffffffg
ggggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhe
eeeeeeeeeeeeeeeeeeeeeee
</div>
<div
id="scrollmenu"
style="position:absolute;width:236px;height:30px;z-index:1;
left:328px;
top:
44px">
<table
border=1><tr><td>
<table>
<tr>
<td
align=left>Up</td>
<td>
</td>
<td
align=right>Down</td>
</tr>
<tr>
<td
colspan=3>
<a
href="#"
onMouseOver="verScroll(
up
,
25
,
true
)"
onMouseOut="stopScroll()"><<<</a>
<a
href="#"
onMouseOver="verScroll(
up
,
5
,
true
)"
onMouseOut="stopScroll()"><<</a>
<a
href="#"
onMouseOver="verScroll(
up
,
1
,
true
)"
onMouseOut="stopScroll()"><</a>
|
<a
href="#"
onMouseOver="verScroll(
dn
,
1
,
true
)"
onMouseOut="stopScroll()">></a>
<a
href="#"
onMouseOver="verScroll(
dn
,
5
,
true
)"
onMouseOut="stopScroll()">>></a>
<a
href="#"
onMouseOver="verScroll(
dn
,
25
,
true
)"
onMouseOut="stopScroll()">>>></a>
</td>
</tr>
</table>
</td></tr></table>
</div>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式