|
------------------------------------------------------------------------------------------------
上下首尾移动
------------------------------------------------------------------------------------------------
<div id="marquees"> <!-- 这些是字幕的内容,你可以任意定义 --> <a href="#">链接一</a>
<br/> <a href="#">链接二</a>
<br/> <a href="#">链接三</a>
<br/> <a href="#">链接四</a>
<br/> <!-- 字幕内容结束 -->
</div>
<!-- 以下是java-script代码 -->
<script language="javascript">
<!--
marqueesHeight=200; //内容区高度
stopscroll=false; //这个变量控制是否停止滚动
with(marquees){
noWrap=true; //这句表内容区不自动换行
style.width=0; //于是我们可以将它的宽度设为0,因为它会被撑大
style.height=marqueesHeight;
style.overflowY="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(){ //初始化滚动内容
//多次复制原内容到"templayer",直到"templayer"的高度大于内容区高度:
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
} //把"templayer"的内容的“两倍”复制回原内容区:
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
//设置连续超时,调用"scrollUp()"函数驱动滚动条:
setInterval("scrollUp()",10);
}
document.body.onload=init;
preTop=0; //这个变量用于判断滚动条是否已经到了尽头
function scrollUp(){ //滚动条的驱动函数
if(stopscroll==true) return; //如果变量"stopscroll"为真,则停止滚动
preTop=marquees.scrollTop; //记录滚动前的滚动条位置
marquees.scrollTop+=1; //滚动条向下移动一个像素
//如果滚动条不动了,则向上滚动到和当前画面一样的位置
//当然不仅如此,同样还要向下滚动一个像素(+1):
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight+1;
}
}
-->
</script>
-------------------------------------------------------------------------------
左右首尾移动
-------------------------------------------------------------------------------
<SCRIPT>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee1(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
} }
var MyMar1=setInterval(Marquee1,speed)
demo.onmouseover=function() {clearInterval(MyMar1)}
demo.onmouseout=function() {MyMar1=setInterval(Marquee1,speed)}
</SCRIPT>
<DIV id=demo style="OVERFLOW: hidden; WIDTH: 1000px; HEIGHT: 155px">
<table cellPadding=0 align=center border=0 cellspace="0">
<tr>
<td id=demo1 vAlign=top><table width='100%' border='0' cellspacing='0' cellpadding='2'>
<tr>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=94'><img src='../cioupload/20099517265211713.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=94'>条幅布</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=93'><img src='../cioupload/2009951726967430.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=93'>750写真机喷头</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=92'><img src='../cioupload/200982922302375861.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=92'>写真墨水</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=81'><img src='../cioupload/2009861042888149.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=81'>写真机显示屏</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=80'><img src='../cioupload/20098610353750514.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=80'>全自动横幅机主板</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=79'><img src='../cioupload/20098610303463198.bmp' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=79'>全自动横幅机主板</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=78'><img src='../cioupload/20098610282943532.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=78'>写真机主板和小车板</a></td>
</tr>
</table></td>
<td><table width=130 border=0 cellspacing=0 cellpadding=0>
<tr>
<td align='center'><a href='product.asp?ID=77'><img src='../cioupload/20098610255921005.jpg' border='0' width='150' height='123' style='border:2px solid #F2F2F2'></a><br>
<a href='product.asp?ID=77'>写真机内存</a></td>
</tr>
</table></td>
</tr>
</table></td>
<td id=demo2 vAlign=top></td>
</tr>
</table>
</DIV> |
|