会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
wood's blog
永不言弃,每天前进一步。快乐学习,快乐生活。
博客园
首页
新随笔
联系
订阅
管理
向上间歇滚动
前台代码
1
<%
@ Control Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
RollNews.ascx.cs
"
Inherits
=
"
Controls_RollNews
"
%>
2
<
div
id
="table01"
style
="width: 300;"
>
3
<
table
width
="158"
height
="420"
border
="0"
cellpadding
="0"
cellspacing
="0"
>
4
<
tr
>
5
<
td
width
="<%=Width %>"
height
="420"
>
6
<
font
size
="2"
>
7
<%
=
RollContent
%>
8
</
font
>
9
</
td
>
10
</
tr
>
11
</
table
>
12
</
div
>
13
14
<
script
>
15
marqueetable
=
document.all.table01;
16
scrollheight
=
180
;
//
滚动显示高度
17
stopscroll1
=
false
;
18
marqueetable.scrollTop
=
0
;
19
20
with
(marqueetable)
21
{
22
style.width
=
'
<%=Width %>
'
;
23
style.height
=
scrollheight;
24
style.overflowX
=
"
hidden
"
;
25
style.overflowY
=
"
hidden
"
;
26
noWrap
=
true
;
27
onmouseover
=
new
Function(
"
stopscroll1=true
"
);
28
onmouseout
=
new
Function(
"
stopscroll1=false
"
);
29
}
30
31
startmarqueetop
=
0
;
32
offsettop
=
1
;
33
marqueestoptime
=
0
;
34
//
marqueetable.innerHTML+=marqueetable.innerHTML;
35
36
function
setmarqueetime()
37
{
38
marqueetable.scrollTop
=
0
;
39
setInterval(
"
marqueeup()
"
,
'
<%=RollTime %>
'
);
//
设置滚动的时间
40
}
41
42
setmarqueetime();
43
44
function
marqueeup()
45
{
46
if
(stopscroll1
==
true
)
return
;
47
offsettop
+=
1
;
48
49
if
(offsettop
==
20
)
50
{
51
marqueestoptime
+=
1
;
52
offsettop
-=
1
;
53
if
(marqueestoptime
==
'
<%=SleepTime %>
'
)
//
停留的时间
54
{
55
offsettop
=
0
;
56
marqueestoptime
=
0
;
57
}
58
}
59
else
60
{
61
startmarqueetop
=
marqueetable.scrollTop;
62
marqueetable.scrollTop
+=
1
;
63
if
(startmarqueetop
==
marqueetable.scrollTop)
64
{
65
marqueetable.scrollTop
=
10
;
66
marqueetable.scrollTop
+=
1
;
67
}
68
}
69
}
70
</
script
>
71
72
后台代码
1
using
System;
2
using
System.Data;
3
using
System.Configuration;
4
using
System.Collections;
5
using
System.Web;
6
using
System.Web.Security;
7
using
System.Web.UI;
8
using
System.Web.UI.WebControls;
9
using
System.Web.UI.WebControls.WebParts;
10
using
System.Web.UI.HtmlControls;
11
12
public
partial
class
Controls_RollNews : System.Web.UI.UserControl
13
{
14
private
string
_RollContent
=
""
;
15
private
int
_Width
=
158
;
16
private
int
_SleepTime
=
1
;
17
private
int
_RollTime
=
50
;
18
public
string
RollContent
19
{
20
get
{
return
_RollContent; }
21
set
{ _RollContent
=
value; }
22
}
23
public
int
Width
24
{
25
get
{
return
_Width; }
26
set
{ _Width
=
value; }
27
}
28
public
int
SleepTime
29
{
30
get
{
return
_SleepTime; }
31
set
{ _SleepTime
=
value; }
32
}
33
public
int
RollTime
34
{
35
get
{
return
_RollTime; }
36
set
{ _RollTime
=
value; }
37
}
38
protected
void
Page_Load(
object
sender, EventArgs e)
39
{
40
41
}
42
}
43
调用:
<%
@ Register Src
=
"
~/Controls/RollNews.ascx
"
TagName
=
"
RollNews
"
TagPrefix
=
"
ucRollNews
"
%>
<
ucRollNews:RollNews
ID
="RollNews"
runat
="server"
/>
RollNews.RollContent = "古道西风长城外,夕阳西下漫山红。昨日相思今日忆,梦里几回换真心。共语情歌绕人肠,诗对切切费思量。几许真情言难诉,唯有真心驿动中。
<
br
>
";
人的一生应该这样度过:当他回首往事的时候,不会因为虚度年华而悔恨,也不会因为碌碌无为而羞愧。
posted @
2008-04-09 23:42
yellowwood
阅读(
310
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告
Never Give UP