当前位置: 电脑软硬件应用网 > 设计学院 > 网页特效 > 正文
层的渐显闪烁效果
层的渐显闪烁效果
2005-12-30 19:02:14  文/45IT收集   出处:电脑软硬件应用网   

用这段代码做文字广告或公告栏之类的东西实在是太合适了,代码量不大,实现的效果却非常酷,引人注意。而且在版面的安排上也特别方便。 
<script language="JavaScript1.2">
var delay=3000 //set delay between message change (in miliseconds)
var fcontent=new Array()
begintag='<font face="Arial" size=2>' //set opening tag, such as font declarations
fcontent[0]="<b>What\'s new?</b><br>New scripts added to the Scroller
 category!<br><br>The MoreZone has been updated"
fcontent[1]="Dynamic Drive has been featured on Jars as a top 5% resource,
 and About.com as a recommended DHTML destination"
fcontent[2]="Ok, enough with these pointless messages. You get the idea
 behind this script."closetag='</font>'

var fwidth=150 //set scroller width
var fheight=150 //set scroller height

///No need to edit below this line/////////////////

var ie4=document.all&&!document.getElementById
var ns4=document.layers
var DOM2=document.getElementById
var faderdelay=0
var index=0

if (DOM2)
faderdelay=2000

//function to change content
function changecontent(){
if (index>=fcontent.length)
index=0
if (DOM2){
document.getElementById("fscroller").style.color="rgb(255,255,255)"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
colorfade()
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag
else if (ns4){
document.fscrollerns.document.fscrollerns_sub.document.write(begintag+fcontent
[index]+closetag)
document.fscrollerns.document.fscrollerns_sub.document.close()
}

index++
setTimeout("changecontent()",delay+faderdelay)
}

// colorfade() partially by Marcio Galli for Netscape Communications.  ////////////
// Modified by Dynamicdrive.com

frame=20;
hex=255  // Initial color value.

function colorfade() {           
// 20 frames fading process
if(frame>0) { 
hex-=12; // increase color value
document.getElementById("fscroller").style.color="rgb("+hex+","+hex+","+hex+")";
 // Set color value.
frame--;
setTimeout("colorfade()",20); 
}
else{
document.getElementById("fscroller").style.color="rgb(0,0,0)";
frame=20;
hex=255
}   
}

if (ie4||DOM2)
document.write('<div id="fscroller" style="border:1px solid 
black;width:'+fwidth+';height:'+fheight+';padding:2px"></div>')

window.onload=changecontent
</script>


<ilayer id="fscrollerns" width=&{fwidth}; height=&{fheight};>
<layer id="fscrollerns_sub" width=&{fwidth}; height=&{fheight}; 
left=0 top=0></layer></ilayer>


http://nic-002.nicchina.com/

  • 上一篇文章:

  • 下一篇文章:
  • 最新热点 最新推荐 相关文章
    网页特效代码:仿京东的商品分类导航…
    不能屏蔽的网页右下角窗口特效
    装载页面进度条代码
    链接特效之js做引用文章链接代码
    左右移动转换文字特效HTML代码解析
    网页页面实现自动刷新的3种代码
    网页特效代码:纯css下拉菜单列表
    JS特效代码:实现间歇无缝文字滚动特…
    文字滚动特效(兼容多浏览器)
    网页特效代码:JavaScript显示系统时…
    关于45IT | About 45IT | 联系方式 | 版权声明 | 网站导航 |

    Copyright © 2003-2011 45IT. All Rights Reserved 浙ICP备09049068号