它是可以兼容火狐了,但它过一会就停止,我想让它永远不停,但又不会修改代码,请高手帮修改,代码如下: <!--下面是向上滚动代码-->
<div id="colee" style="overflow:hidden;height:253px;width:750px;">
<div id="colee1">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
</div>
<div id="colee2"></div>
</div>
<script>
var speed=30;
var colee2=document.getElementById("colee2");
var colee1=document.getElementById("colee1");
var colee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML; //克隆colee1为colee2
function Marquee1(){
//当滚动至colee1与colee2交界时
if(colee2.offsetTop-colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight; //colee跳到最顶端
}else{
colee.scrollTop++
}
}
var MyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function() {clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script><!--向上滚动代码结束-->
<div id="colee" style="overflow:hidden;height:253px;width:750px;">
<div id="colee1">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
</div>
<div id="colee2"></div>
</div>
<script>
var speed=30;
var colee2=document.getElementById("colee2");
var colee1=document.getElementById("colee1");
var colee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML; //克隆colee1为colee2
function Marquee1(){
//当滚动至colee1与colee2交界时
if(colee2.offsetTop-colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight; //colee跳到最顶端
}else{
colee.scrollTop++
}
}
var MyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function() {clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script><!--向上滚动代码结束-->
解决方案 »
- jquery ajax问题
- 这么晚了我还在赶工,帮我看看display none 占位置不走了?
- 这些JS的变量 怎么在JAVA里面表示 有没有高手看下。可以这样改么
- ExtJs的PagingToolBar只能显示第一页
- 如何用JavaScript改变TextBox背景色?
- 请教:如何用Javascript获取IE的刷新事件,当用户点击IE的刷新按钮或者按F5时。。取消当前事件(刷新动作)而去执行子框架的刷新一鸣惊人事
- 关于事件的问题
- 我写一个考试倒计时的JS函数。。。哪位高手能给代码。。。谢拉
- 请使用WindowsXp的朋友们帮我测试下面一段代码!
- 我怎样访问一个插入的图片
- 子页面控制父页面打开新页面
- ExtJs表单验证问题
两种办法解决问题:
一、重写计算offsetTop的方法。
二、将offsetTop改为offsetHeight。
function OffsetTop(obj){
var _top = obj.offsetTop;
while(obj = obj.offsetParent){
_top += obj.offsetTop;
}
return _top;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<!--下面是向上滚动代码-->
<div id="colee" style="overflow:hidden;height:253px;width:750px;">
<div id="innerDom" style="height:800%;">
<div id="colee1">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
</div>
<div id="colee2"></div>
</div>
</div>
<script>
var speed=30;
var colee2=document.getElementById("colee2");
var colee1=document.getElementById("colee1");
var colee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML; //克隆colee1为colee2
function Marquee1(){
//当滚动至colee1与colee2交界时
if(colee2.offsetHeight - colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight; //colee跳到最顶端
}else{
colee.scrollTop++
}
}
var MyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function() {clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script><!--向上滚动代码结束-->
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<!--下面是向上滚动代码-->
<div id="colee" style="overflow:hidden;height:253px;width:750px;">
<div id="innerDom" style="height:800%;">
<div id="colee1">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
<img src="img/01.gif">
<img src="img/02.gif">
<img src="img/03.gif">
<img src="img/04.gif">
</div>
<div id="colee2"></div>
</div>
</div>
<script>
function OffsetTop(obj){
var _top = obj.offsetTop;
while(obj = obj.offsetParent){
_top += obj.offsetTop;
}
return _top;
}
var speed=30;
var colee2=document.getElementById("colee2");
var colee1=document.getElementById("colee1");
var colee=document.getElementById("colee");
colee2.innerHTML=colee1.innerHTML; //克隆colee1为colee2
function Marquee1(){
//当滚动至colee1与colee2交界时
if(OffsetTop(colee2) - colee.scrollTop<=0){
colee.scrollTop-=colee1.offsetHeight; //colee跳到最顶端
}else{
colee.scrollTop++
}
}
var MyMar1=setInterval(Marquee1,speed)//设置定时器
//鼠标移上时清除定时器达到滚动停止的目的
colee.onmouseover=function() {clearInterval(MyMar1)}
//鼠标移开时重设定时器
colee.onmouseout=function(){MyMar1=setInterval(Marquee1,speed)}
</script><!--向上滚动代码结束-->
</body>
</html>