我把你给我参考的那段代码全部存成一个新的HTM文件,然后在FIREFOX中打开,根本就不滚动。
所以我也就没仔细再往下看。
所以我也就没仔细再往下看。
解决方案 »
- JS面向对象语法问题
- js实现无前台无限级分类
- 怎样在关闭子窗口的时候同时也把父窗口也关了
- IE和firefox兼容
- IsNan函数在asp.net中用不起来?
- 太简单问题,没有先例,只好提问散分!如何清空一个只读的文本框?
- 怎样在页面上用<OBJECT>标记播放mp3?在线急等!!!
- 高手救急!怎样在一个网页中读取另一个网页的信息?
- 求问关于webstorm为什么代码生成后和在原网页生成的不一样
- 置顶 上移 下移 置底 删除 麻烦各位帮忙看看,s
- 高手帮忙,新手求救,求一个js代码。 类似gmail上传附件的,添加一个附件。。。再添加一个附件
- 请教大家怎么写的用javascript写邮箱验证(50分)
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
-->
</style></head>
<body>
<div id="demo" style="overflow:hidden; width:300px; height:132px; line-height:20px;">
<div id="demo1">
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111
</div>
<div id="demo2"></div>
</div>
<script language="javascript">
var speed=30
document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML
function Marquee(){ if(document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop<=0)
document.getElementById("demo").scrollTop-=document.getElementById("demo1").offsetHeight
else{
document.getElementById("demo").scrollTop++
}
document.getElementById("a").innerHTML=document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop;
}
var MyMar=setInterval(Marquee,speed)
document.getElementById("demo").onmouseover=function() {clearInterval(MyMar)}
document.getElementById("demo").onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
<div id="a"></div>
</body>
</body>
</html>
你自己看就知道了
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111<br>
11111111
</div>
这里,面的最后一行11111111删掉,你对比一下,然后仔细观察<div id="a"></div>
这个的值的变化就知道了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>test</title>
<style>
body {font: 12px, Arial, Helvetica, sans-serif;color: #808080;}
a:visited, a:link {color: #808080; text-decoration: none;}
a:hover {color: #2359B1;}
#wrapper { margin:0 auto;width:960px; background-color:#FFF; height:auto; overflow: hidden;}
#content{ width:960px; height:auto; overflow:hidden; clear:both;margin-top:10px;}
#side{ FLOAT: left; OVERFLOW: hidden; WIDTH: 215px; HEIGHT: auto; BACKGROUND-COLOR: #fafafa}
.cartbox{width:189px; border:5px solid #cccccc; margin-bottom:5px; margin-top:0px; line-height:25px; padding:8px;}
.invoicequery{border: 1px solid #A5E26B; width:213px; margin-bottom:5px;}
.invoicequery .title{ background:url(images/menu_bg.gif); height:27px;font-size:14px; font-weight:bold; line-height:25px; padding-left:10px; padding-top:6px;}
.invoicequery .content{width:203px;border-top:1px dashed #DADADA; margin-left:5px; padding-top:5px; margin-bottom:0px; padding-bottom:5px;}
.invoicequery .content .invoicebox ul{ height:18px; width:189px; margin:0px; margin-left:6px; padding-left:0px; padding-top:0px!important; padding-top:2px; padding-bottom:2px; background: #F7F7F7}
.invoicequery .content .invoicebox .odb{border:1px dashed #DADADA;border-bottom:none}
.invoicequery .content .invoicebox .ivb{border:1px dashed #DADADA; margin-bottom:5px;}
.invoicequery .content .invoicebox li{ line-height:16px; list-style-type:none; float:left;}
.invoicequery .content .invoicebox .tt{ width:60px; padding-left:6px; padding-top:2px!important; padding-top:3px;}
#demo{overflow:hidden; height:148px!important; height:160px;}
</style>
</head>
<body>
<div id="wrapper">
<div id="content">
<div id="side">
<div class="cartbox"><a href="../shop/mycart.php" title="查看购物车">您的购物车中有 0 件商品,总计金额 ¥0.00元。</a></div>
<div class="invoicequery">
<div class="title">发货单号查询</div>
<div class="content">
<div class="invoicebox">
<div id="demo">
<div id="demo1">
<ul class="odb"><li class="tt">订货单号</li><li>2008100672310</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>34324323434</li></ul>
<ul class="odb"><li class="tt">订货单号</li><li>2008100609437</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>frrrt</li></ul>
<ul class="odb"><li class="tt">订货单号</li><li>2008100643652</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>3432432343</li></ul>
<ul class="odb"><li class="tt">订货单号</li><li>2008100629784</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>3431112</li></ul>
<ul class="odb"><li class="tt">订货单号</li><li>2008100666583</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>3333333333</li></ul>
<ul class="odb"><li class="tt">订货单号</li><li>2008092583610</li></ul>
<ul class="ivb"><li class="tt">发货单号</li><li>333333</li></ul>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
var speed=50
document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML
function Marquee(){
if(document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop<=0)
document.getElementById("demo").scrollTop-=document.getElementById("demo1").offsetHeight
else{
document.getElementById("demo").scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
document.getElementById("demo").onmouseover=function() {clearInterval(MyMar)}
document.getElementById("demo").onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</div>
</div>
</div>
</div>
</div>
</body>
</html>这是我的代码,在FIREFOX下,每循环滚动2次就停止了。
但如果直接把ID为invoicequery直接放在BODY里,就不会停止了。
帮我看看问题出在哪里?
你的JS只要改成:<script>
var speed=50
document.getElementById("demo2").innerHTML=document.getElementById("demo1").innerHTML
function Marquee(){
if(document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop<=0)
document.getElementById("demo").scrollTop-=document.getElementById("demo1").offsetHeight
else{
document.getElementById("demo").scrollTop++
}
document.getElementById("a").innerHTML=document.getElementById("demo2").offsetTop-document.getElementById("demo").scrollTop;
}
var MyMar=setInterval(Marquee,speed)
document.getElementById("demo").onmouseover=function() {clearInterval(MyMar)}
document.getElementById("demo").onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>然后再加一个<div id="a"></div>你就发现,FF下a的值无法达到0,所以就停止了
DIV在IE和FF下的offsetTop值是不一样的
就可以了