有没有比较简单容易实现的代码啊?
参考代码:
————————————————————————————————————————
<style type="text/css">
.gradualshine{
filter:alpha(opacity=30);
-moz-opacity:0.3;
}
</style>
<script type="text/javascript">
var baseopacity=30
function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}
function slowlow(which2){
cleartimer()
instantset(baseopacity)
}
function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}
function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}
function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
</script>
<DIV id=demo style="OVERFLOW: hidden; WIDTH:580px; HEIGHT:80px">
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD id=demo1>
<TABLE cellSpacing=0 cellPadding=3 >
<TBODY>
<TR vAlign=top align=left width="360">
<TD><IMG height=80 src="images/photo1.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo2.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo3.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo4.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo5.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo6.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo7.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo8.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo9.jpg" width=120
border=0></TD>
<TD><IMG height=80 src="images/photo10.jpg" width=120
border=0></TD>
</TR></TBODY></TABLE></TD>
<TD id=demo2></TD></TR></TBODY>
</TABLE>
</DIV>
<SCRIPT>
var speed=20
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function(){clearInterval(MyMar)}
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)}
</SCRIPT>
我在网上找的,大家借鉴一下吧!!!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<div id="marquees"> <!-- 这些是字幕的内容,你可以任意定义 -->
<a href=""><img src=" " style="width:120px;height:120px;border:0px;" alt="test"/></a>
<a href=""><img src=" " style="width:120px;height:120px;border:0px;" alt="test"/></a>
<a href=""><img src=" " style="width:120px;height:120px;border:0px;" alt="test"/></a>
<a href=""><img src=" " style="width:120px;height:120px;border:0px;" alt="test"/></a>
<!-- 字幕内容结束 -->
</div>
<!-- 以下是java-scrīpt代码 -->
<scrīpt language="javascrīpt">
<!--
marqueesWidth=480; //内容区宽度度
stopscroll=false; //这个变量控制是否停止滚动
with(marquees){
noWrap=true; //这句表内容区不自动换行
style.width=marqueesWidth; //于是我们可以将它的宽度设为0,因为它会被撑大
style.height=0;
style.overflowX="hidden"; //滚动条不可见
onmouseover=new Function("stopscroll=true"); //鼠标经过,停止滚动
onmouseout=new Function("stopscroll=false"); //鼠标离开,开始滚动
}
//这时候,内容区的高度是无法读取了。下面输出一个不可见的层"templayer",稍后将内容复制到里面:
document.write('<div id="templayer"style="position:absolute;z-index:1;visibility:hidden"></div>');
function init(){ //初始化滚动内容
while(templayer.offsetWidth<marqueesWidth){
templayer.innerHTML+=marquees.innerHTML;
} //把"templayer"的内容的“两倍”复制回原内容区:
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
//设置连续超时,调用"scrollUp()"函数驱动滚动条:
setInterval("scrollUp()",20);
}
document.body.onload=init;
preTop=0; //这个变量用于判断滚动条是否已经到了尽头
function scrollUp(){ //滚动条的驱动函数
if(stopscroll==true) return; //如果变量"stopscroll"为真,则停止滚动
preTop=marquees.scrollLeft;
marquees.scrollLeft+=1;
//如果滚动条不动了,则向上滚动到和当前画面一样的位置
//当然不仅如此,同样还要向下滚动一个像素(+1):
if(preTop==marquees.scrollLeft){
marquees.scrollLeft=templayer.offsetHeight-marqueesWidth+1;
}
}
-->
</scrīpt>
</body>
</html>