怎么能让一段文字一行一行的渐渐显示出来?

yunfeifan 2002-08-16 09:34:37
有一段文字(几行),怎么能一行一行的渐渐显示出来(已经显示出来的就不变了?)
...全文
1193 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
qiushuiwuhen 2002-08-16
  • 打赏
  • 举报
回复
<style>#h{width:100%;filter:alpha(opacity=0,style=1)}</style>
<span id=h>第1行</span>
<span id=h>第2行</span>
<span id=h>第3行</span>
<span id=h>第4行</span>
<script>
var objs=document.getElementsByName("h");n=0;
var timer=setInterval(show,100);
function show(){
if((n+=5)>=100*objs.length)clearInterval(timer);
else objs[Math.floor(n/100)].filters.alpha.opacity=n%100;
}
</script>
willway 2002-08-16
  • 打赏
  • 举报
回复
<html>

<head>
<title>隐现文字</title>
<style type="text/css">
<!--
.textanimlink,a {
text-decoration : none;
}
P.main {
font-family : 宋体;
font-size : 15pt;
font-weight : bold;
}
-->
</style>
</head>

<!-- 代码开始 -->
<script Language="javascript">
bname=navigator.appName;
bversion=parseInt(navigator.appVersion)
if ((bname=="Netscape" && bversion>=4) || (bname=="Microsoft Internet Explorer" && bversion>=4))
window.onload=start
else
stop();
window.onunload=stop
if (bname=="Netscape"){
brows=true
dt=2
}
else{
brows=false
dt=20
}
var z=0;
var msg=0;
var rgb=0;
var link=false;
var status=true;
var updwn=false;
var message= new Array();
var value=0;
var h=window.innerHeight;
var w=window.innerWidth;
var timer1;
var timer2;
var timer3;
var convert = new Array()
var hexbase= new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");

var bgcolor="#000000"; //Color of background
var color="#00ff00"; //Color of the Letters

message[0]='欢迎你进入中国素材网'
message[1]='网址:http://www.sucai.org'
message[2]='30000张网页素材供您选择'
message[3]='中国素材网 永远将最好的留给您! </a>'

for (x=0; x<16; x++){
for (y=0; y<16; y++){
convert[value]= hexbase[x] + hexbase[y];
value++;
}
}

redx=color.substring(1,3);
greenx=color.substring(3,5);
bluex=color.substring(5,7);
hred=eval(parseInt(redx,16));
hgreen=eval(parseInt(greenx,16));
hblue=eval(parseInt(bluex,16));
eredx=bgcolor.substring(1,3);
egreenx=bgcolor.substring(3,5);
ebluex=bgcolor.substring(5,7);
ered=eval(parseInt(eredx,16));
egreen=eval(parseInt(egreenx,16));
eblue=eval(parseInt(ebluex,16));
red=ered;
green=egreen;
blue=eblue;

function start(){
if ((bname=="Netscape" && bversion>=4) || (bname=="Microsoft Internet Explorer" && bversion>=4)){
link=false;
updwn=true;
if (brows)
res=document.layers['textanim'].top
else{
textanim.style.width=document.body.offsetWidth-20;
textanim.innerHTML='<Pre><P Class="main" Align="Center">'+message[msg]+'</P></Pre>'
res=textanim.style.top
for (x=0; x<document.all.length; x++)
if(document.all[x].id=="textanimlink")
link=true;
}
up()
}
}

function stop(){
clearTimeout(timer1);
clearTimeout(timer2);
clearTimeout(timer3);
}

function resz(){
h=window.innerHeight;
w=window.innerWidth;
if (updwn)
timer1=setTimeout('up()',1000)
else
timer2=setTimeout('down()',1000)
}

function breakf(){
if (status){
clearTimeout(timer1);
clearTimeout(timer2);
status=false
return;
}
else{
status=true;
if (updwn)
timer1=setTimeout('up()',dt)
else
timer2=setTimeout('down()',dt)
}
}


function up(){
if (red<hred){
if ((red+7)<hred)
red+=7;
else
red=hred
redx = convert[red]
}
else{
if ((red-7)>hred)
red-=7;
else
red=hred
redx = convert[red]
}

if (green<hgreen){
if ((green+7)<hgreen)
green+=7;
else
green=hgreen
greenx = convert[green]
}
else{
if ((green-7)>hgreen)
green-=7;
else
green=hgreen
greenx = convert[green]
}

if (blue<hblue){
if ((blue+7)<hblue)
blue+=7;
else
blue=hblue
bluex = convert[blue]
}
else{
if ((blue-7)>hblue)
blue-=7;
else
blue=hblue
bluex = convert[blue]
}

rgb = "#"+redx+greenx+bluex;
if (brows){
document.layers['textanim'].document.linkColor=rgb;
document.layers['textanim'].document.vlinkColor=rgb;
if (window.innerHeight!=h || window.innerWidth!=w){
clearTimeout(timer1);
resz()
return;
}
else{
document.layers['textanim'].document.write('<Pre><P Class="main" Align="Center"><font color="'+rgb+'">'+message[msg]+'</font></P></Pre>')
document.layers['textanim'].document.close();
}
}
else{
textanim.style.color=rgb;
if(link)
textanimlink.style.color=rgb;
}
if (z<38){
if (brows)
document.layers['textanim'].top--
else
textanim.style.posTop--
z++
timer1=setTimeout('up()',dt)
}
else
{
updwn=false;
down()
}
}


function down(){
if (red<ered){
if ((red+7)<ered)
red+=7;
else
red=ered
redx = convert[red]
}
else{
if ((red-7)>ered)
red-=7;
else
red=ered
redx = convert[red]
}

if (green<egreen){
if ((green+7)<egreen)
green+=7;
else
green=egreen
greenx = convert[green]
}
else{
if ((green-7)>egreen)
green-=7;
else
green=egreen
greenx = convert[green]
}

if (blue<eblue){
if ((blue+7)<eblue)
blue+=7;
else
blue=eblue
bluex = convert[blue]
}
else{
if ((blue-7)>eblue)
blue-=7;
else
blue=eblue
bluex = convert[blue]
}

rgb = "#"+redx+greenx+bluex;
if (brows){
document.layers['textanim'].document.linkColor=rgb;
document.layers['textanim'].document.vlinkColor=rgb;
if (window.innerHeight!=h || window.innerWidth!=w){
clearTimeout(timer2);
resz()
return;
}
else{
document.layers['textanim'].document.write('<Pre><P Class="main" Align="Center"><font color="'+rgb+'">'+message[msg]+'</font></P></Pre>')
document.layers['textanim'].document.close();
}
}
else{
textanim.style.color=rgb;
if(link)
textanimlink.style.color=rgb;
}

if (z<76){
if (brows)
document.layers['textanim'].top--
else
textanim.style.posTop--
z++
timer2=setTimeout('down()',dt)
}
else
{
if (brows){
document.layers['textanim'].document.write('')
document.layers['textanim'].document.close();
}
else
textanim.innerHTML='';
window.clearInterval(timer2);
if(msg<message.length-1){
msg++;
z=0;
if (brows){
document.layers['textanim'].top=res;
}
else
textanim.style.top=res;
timer3=setTimeout('start()',100);
}
else
{
msg=0;
z=0;
if (brows)
document.layers['textanim'].top=res;
else
textanim.style.top=res;
timer3=setTimeout('start()',2000);
}
}
}

</script>
<!-- 代码结束 -->


<body bgcolor=#000000>
<div id="textanim" style="position: absolute; left: 0; top: 200" onclick="breakf()"></div><Layer name="textanim" left="0" top="200">
</Layer>
<center>
<p>
<input TYPE="BUTTON" value="查看源代码" onClick="window.location.href='view-source:'+window.location.href">
</p>
<p>
<input onclick="window.close()"; type=button value=关闭窗口>
</center>
</body>
</html>
yunfeifan 2002-08-16
  • 打赏
  • 举报
回复
请问谁还有比较直接的方法,因为我的需求就是一行一行的渐渐显示出来!
JavaCoffee 2002-08-16
  • 打赏
  • 举报
回复
给你个例子参考一下:
<HTML><head><title>IIS 漫游幻灯片 1</title>

<META NAME="ROBOTS" CONTENT="NOINDEX">

<SCRIPT Language="VBScript"> <!--

'Declare the variable used to increment the x coordinate
Public XPos
'Initialize the variable
XPos = 20

Function LightMe()
'Puts a spotlight on the title
call document.all.title.filters(0).addPoint(20, 10, 100, 200, 225, 200, 100)
MoveLight
End Function

Function MoveLight()
'Moves the spotlight from left to right across the title area until it reaches the edge
'of the window and then stops
'This increments the x coordinate
XPos = XPos + 5
'If not at the right edge of the window then move the spotlight right
If XPos < 480 Then
call document.all.title.filters(0).movelight(0, xpos, 10, 100, 1)
myTimer = window.setTimeout("Movelight", 1)
'If at the right edge of the window call the first paragraph of text
Else
window.clearTimeout(myTimer)
call document.all.title.filters(0).clear
Text1Trans
End If
End Function

Sub Text1Trans()
'Makes the first paragraph of text visible
Text1.filters(0).Apply()
Text1.style.visibility="visible"
Text1.filters(0).Play()
myTimer = window.setTimeout("Text2Trans", 3000)
End Sub

Sub Text2Trans()
'Makes the second paragraph of text visible
Text2.filters(0).Apply()
Text2.style.visibility="visible"
Text2.filters(0).Play()
Link2Trans
End Sub

Sub Link2Trans()
'Makes the Next button visible
Link2.filters(0).apply()
Link2.style.visibility="visible"
Link2.filters(0).play()
End Sub

Sub Next_onclick()
'Makes the button appeared depressed and moves to next slide
document.all.ButtonNext.src = "right3down.gif"
location.href= "iitourb.htm"
End Sub
-->
</script>

<META HTTP-EQUIV="Content-Type" content="text/html; charset=gb2312">
<META NAME="MS.LOCALE" CONTENT="ZH-CN">
<style>
body,div,td{font:menu}
</style>
</head>

<BODY onload="LightMe" BGCOLOR="#800000" TEXT="#D4B878" >


<Div id="title" style="position:absolute; left:7; top:7; width:425; visibility:visible; filter:Light"><strong>欢迎使用 Internet 信息服务!</strong></Div>

<div id="Text1" style="position: absolute;left: 7; top: 45; width: 425; visibility: hidden; filter: revealTrans(Duration=2, Transition=19); height: 39"><strong><font color="#D4B878">Microsoft Internet 信息服务是一个桌面 Web 服务器,使用它,您可以从自己的计算机上发布个人主页,并把您计算机上的文档共享到整个网络。</font>
</strong></div>

<div id="Text2" style="position: absolute; left: 200; top: 175; width: 225; visibility: hidden; filter: revealTrans(Duration=3, Transition=12); height: 39"><strong><font color="#D4B878">在将站点上载到 Internet 提供商之前,也可以将 IIS 用作开发平台。</font></strong></div>

<div id="Link2" style="position:absolute; top:285; left:385; visibility:hidden; filter:revealTrans(Duration=3, Transition=12)" > </div>

<div id="NextButton" style="display:none"><img src=right3down.gif></div>
</body>
</html>
yunfeifan 2002-08-16
  • 打赏
  • 举报
回复
对。第一行渐渐显示出来,第二行渐渐显示出来。。。。。
已经显示出来的就不动了!
willway 2002-08-16
  • 打赏
  • 举报
回复
是不是象flash效果那样一行一行的出现,而不是整篇文章出现?
yunfeifan 2002-08-16
  • 打赏
  • 举报
回复
thank 我想要的是渐渐显示出来的,不是一下子显示出来的!
saucer 2002-08-16
  • 打赏
  • 举报
回复 1
put 文字 in div's, something like

<div id="dv1" style="visibility:hidden">djfladfas</div>
<div id="dv2" style="visibility:hidden">djfladfas</div>
<div id="dv3" style="visibility:hidden">djfladfas</div>
....
<script language="javascript">
var n=0;
function showDiv()
{
n++;
if (n<=100) //if you have 100 div's
{
document.all("dv"+n).style.visibility="visible";
setTimeout("showDiv()",1000);//每隔一秒
}
}
window.onload = showDiv;
</script>

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧