首页 > 其他 > 详细

淡入淡出文字垂直滚动

时间:2014-08-11 11:45:52      阅读:463      评论:0      收藏:0      [点我收藏+]
  • 淡入淡出文字垂直滚动,依次向上垂直滚动,渐渐消失,效果很不错,只是代码稍嫌多,用的时候你可以将JS部分另存为一个文件,于你的网页分开,这样不会影响你的网页。
<html>
<head>
<title>石家庄渣浆泵</title>
</head>
<BODY onLoad="start()" onUnload="stop()">
<Script Language="Javascript">
bname=navigator.appName;
bversion=parseInt(navigator.appVersion)
if ((bname=="Netscape"  &&  bversion>=4) || (bname=="Microsoft Internet Explorer"  &&  bversion>=4)){
if (bname=="Netscape"){
brows=true
dt=1
}
else{
brows=false
dt=40
}
var z=0;
var msg=0;
var rgb=0;
var status=true;
var updwn=false;
var message= new Array();
var value=0;
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="#FFFFFF"; 
var color="#0000FF";  
message[0]=源码爱好者
message[1]=为大家奉献高质量学习型源代码
message[2]=欢迎大家光临
message[3]=再见,下次现来
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)){
if (brows)
res=document.layers[textanim].top
else
res=textanim.style.top
updwn=true;
timer1=window.setInterval(up(),dt)
}
}

function stop(){
if ((bname=="Netscape"  &&  bversion>=4) || (bname=="Microsoft Internet Explorer"  &&  bversion>=4)){
window.clearInterval(timer1);
window.clearInterval(timer2);
window.clearTimeout(timer3);
}
}

function breakf(){
if (status){
window.clearInterval(timer1);
window.clearInterval(timer2);
window.clearTimeout(timer3);
status=false
return;
}
else{
if (updwn)
timer1=window.setInterval(up(),dt)
else
timer2=window.setInterval(down(),dt)
status=true;
}
}


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

if (red>hred){
if ((red-15)>hred){
red-=15;
redx = convert[red]
}
else{
red=hred
redx = convert[red]
}
}

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

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

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

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

rgb = "#"+redx+greenx+bluex;
if (brows){
document.layers[textanim].document.linkColor=rgb;
document.layers[textanim].document.vlinkColor=rgb;
document.layers[textanim].document.writeln(<Pre><P Class="main" Align="Center"><font color="+rgb+">+message[msg]+</Pre>)
document.layers[textanim].document.close();
}
else{
textanim.document.linkColor=rgb;
textanim.document.vlinkColor=rgb;
textanim.innerHTML=<Pre><P Class="main" Align="Center"><font color="+rgb+">+message[msg]+</Pre>
}
if (z<19){
if (brows)
document.layers[textanim].top-=2
else
textanim.style.posTop-=2
z++
}
else
{
updwn=false;
window.clearInterval(timer1);
timer2=window.setInterval(down(),dt)
}
}

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

if (red>ered){
if ((red-15)>ered){
red-=15;
redx = convert[red]
}
else{
red=ered
redx = convert[red]
}
}

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

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

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

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

rgb = "#"+redx+greenx+bluex;
if (brows){
document.layers[textanim].document.linkColor=rgb;
document.layers[textanim].document.vlinkColor=rgb;
document.layers[textanim].document.writeln(<Pre><P Class="main" Align="Center"><font color="+rgb+">+message[msg]+</Pre>)
document.layers[textanim].document.close();
}
else{
textanim.document.linkColor=rgb;
textanim.document.vlinkColor=rgb;
textanim.innerHTML=<Pre><P Class="main" Align="Center"><font color="+rgb+">+message[msg]+</Pre>
}
if (z<38){
if (brows)
document.layers[textanim].top-=2
else
textanim.style.posTop-=2
z++
}
else
{
if (brows){
document.layers[textanim].document.writeln(‘‘)
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=window.setTimeout(start(),100);
}
else
{
msg=0;
z=0;
if (brows)
document.layers[textanim].top=res;
else
textanim.style.top=res;
timer3=window.setTimeout(start(),2000);
}
}
}
}
</Script>
<Div id="textanim" style="position: absolute; left: 18px; top: 100px" onclick="breakf()"> 
</Div>
<layer name="textanim" left=4 top=80> </layer>
</body>
</html>

 

淡入淡出文字垂直滚动,布布扣,bubuko.com

淡入淡出文字垂直滚动

原文:http://www.cnblogs.com/youtianxia/p/3904106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!