多条问候语句交替显示

时间:2007-09-02 11:46:13   来源:  作者:  点击:次  出处:技术无忧
关键字:JavaScript 显示

代码如下:

  要完成此效果把如下代码加入到<body>区域中
<script language="JavaScript1.2">
var delay=2000
var scrollwidth=210
var scrollheight=75
var message=new Array()
var openingtag='<font face="Arial" size=3 color=FF9900>'
message[0]='<b>i love you </b>'
message[1]='<b>i love you jojoo</b>'
message[2]='<b>jojoo i love you too</b>'
var closingtag='</font>'
var hoffset=-10
</script>
<ilayer width=&{scrollwidth}; height=&{scrollheight}; name="sslide">
<layer name="sslide2" width=&{scrollwidth}; height=&{scrollheight};></layer>
</ilayer>
<script language="JavaScript1.2">
var inc=1
var ns4=document.layers
var ie5ns6=document.getElementById||document.all
if (ie5ns6)
document.write(openingtag+'<div id="flyin" style="position:relative;width:'+scrollwidth+';height:'+scrollheight+';">'+message[0]+'</div>'+closingtag)
function updatemsg(){
crossobj.style.left=-2000
crossobj.style.fontStyle="italic"
crossobj.innerHTML=message[inc]
crossobj.style.left=crossobj.offsetWidth*(-1)+hoffset
start=setInterval("animatein()",50)
inc=(inc<message.length-1)? inc+1 : 0
}
function animatein(){
if (parseInt(crossobj.style.left)<0)
crossobj.style.left=parseInt(crossobj.style.left)+20
else{
crossobj.style.left=0
crossobj.style.fontStyle="normal"
clearInterval(start)
}
}
function updatemsgns4(){
document.sslide.document.sslide2.document.write(openingtag+message[inc]+closingtag)
document.sslide.document.sslide2.document.close()
inc=(inc<message.length-1)? inc+1 : 0
}
function initialize(){
if (ie5ns6){
crossobj=document.getElementById? document.getElementById("flyin") : document.all.flyin
setInterval("updatemsg()",delay+1000)
}
else if (ns4){
document.sslide.document.sslide2.document.write(openingtag+message[0]+closingtag)
document.sslide.document.sslide2.document.close()
setInterval("updatemsgns4()",delay)
}
}
window.onload=initialize
</script>

拥有帝国一切,皆有可能。欢迎访问phome.net

文章评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

特别推荐