网站地图    收藏   

主页 > 前端 > javascript >

文字图片向上滚动的JS代码

来源:自学PHP网    时间:2014-09-19 14:47 作者: 阅读:

[导读] 文字图片向上滚动是很多网站像通知,公告都会用到的一种效果了,下面我来来给大家收藏了两种文字图片向上滚动的JS代码有需要的朋友可参考。...

代码一

 代码如下 复制代码

<div id="demo">
<div id="demo1">
<ul>
<li>
文字图片内容
</li>
</ul>
</div>
<div id="demo2"></div>

<script type="text/javascript">
var speed=10;
var FGDemo=document.getElementById('demo');
var FGDemo1=document.getElementById('demo1');
var FGDemo2=document.getElementById('demo2');
FGDemo2.innerHTML=FGDemo1.innerHTML
function Marquee1(){
if(FGDemo2.offsetHeight-FGDemo.scrollTop<=0)
FGDemo.scrollTop-=FGDemo1.offsetHeight
else{
FGDemo.scrollTop++
}
}
var MyMar1=setInterval(Marquee1,speed)
FGDemo.onmouseover=function() {clearInterval(MyMar1)}
FGDemo.onmouseout=function() {MyMar1=setInterval(Marquee1,speed)}
</script>

</div>


代码二

 代码如下 复制代码

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//scroller width
var swidth=300
//scroller height
var sheight=100
//scroller's speed;
var sspeed=2
var wholemessage=''
//text: change to your own
wholemessage='<div align="center"><font face=Arial size=3 color="#ffffff">站长特效网</DIV><div align="center">专注于网页特效广告代码,供站长和js爱好者参考。</strong></DIV><div align="center"><strong>站长必备js特效代码 </strong></DIV><div align="center">打造国内最帅的网页特效站。</div><div align="center">欢迎光临www.zzjs.net</div></font>'
function start(){
if (document.all) return
if (document.getElementById){
document.getElementById("slider").style.visibility="show"
ns6marquee(document.getElementById('slider'))
}
else if(document.layers){
document.slider1.visibility="show"
ns4marquee(document.slider1.document.slider2)
}
}
function ns4marquee(whichlayer){
ns4layer=eval(whichlayer)
ns4layer.document.write(wholemessage)
ns4layer.document.close()
sizeup=ns4layer.document.height
ns4layer.top-=sizeup
ns4slide()
}
function ns4slide(){
if (ns4layer.top>=sizeup*(-1)){
ns4layer.top-=sspeed
setTimeout("ns4slide()",100)
}
else{
ns4layer.top=sheight
ns4slide()
}
}
function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
ns6div.innerHTML=wholemessage
ns6div.style.top=sheight
sizeup=sheight
ns6slide()
}
function ns6slide(){
if (parseInt(ns6div.style.top)>=sizeup*(-1)){
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6slide()",100)
}
else{
ns6div.style.top=sheight
ns6slide()
}
}
//  End -->
</script>
<body bgcolor="#fef4d9" onLoad='start()'>

<span style="borderWidth:1; borderColor:red; width:300; height:100;">
<ilayer width=300 height=100 name="slider1" bgcolor="black" visibility=hide>
<layer name="slider2" onMouseover="sspeed=0;" onMouseout="sspeed=2">
</layer>
</ilayer>
<script language="JavaScript">
if (document.all){
document.writeln('<marquee id="ieslider" scrollAmount=2 width=300 height=100 direction=up style="border:1 solid red;background-color:black">')
document.writeln(wholemessage)
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete') ieslider.scrollAmount=2")
document.write('</marquee>')
}
if (document.getElementById&&!document.all){
document.write('<div style="position:relative;overflow:hidden;width:300;height:100;clip:rect(0 302 102 0); background-color:black;border:1px solid red;" onMouseover="sspeed=0;" onMouseout="sspeed=2">')
document.write('<div id="slider" style="position:relative;width:&{swidth};">')
document.write('</div></div>')
}
</script></span>
</body>

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论