当前位置:编程学习 > C#/ASP.NET >>

文字向上滚动的问题

<div id="demo" style="overflow:hidden;"> 
<div id="demo1"> 
<asp:DataList ID="DataList7" runat="server" DataSourceID="SqlDataSource8" Style="border-right: #cccccc 1px solid;
border-top: #cccccc 1px solid; border-left: #cccccc 1px solid; border-bottom: #cccccc 1px solid"
Width="100%">
<ItemTemplate>
<table style="width: 100%">
<tr>
<td>
 <asp:Image ID="Image1" runat="server" ImageUrl="~/images/sign1.gif" />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("nid","newsdetail.aspx?id={0}") %>'
Text='<%# Eval("newtitle").ToString().Length > 10? Eval("newtitle").ToString().Substring(0, 10):Eval("newtitle") %>'></asp:HyperLink>
</td>
</tr>
<tr>
<td style="height: 1px">
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div> 
<div id="demo2"></div> 
</div> 
</td>
</tr>
</table>
<script type="text/javascript"> 
var speed=30;
demo2.innerHTML=demo1.innerHTML;//克隆demo1为demo2 
function Marquee(){ 
//当滚动至demo1与demo2交界时 
if(demo2.offsetTop-demo.scrollTop<=0) 
demo.scrollTop-=demo1.offsetHeight; //demo跳到最顶端 
else{ 
demo.scrollTop++;


var MyMar=setInterval(Marquee,speed);//设置定时器 
//鼠标移上时清除定时器达到滚动停止的目的 
demo.onmouseover=function() {clearInterval(MyMar);} 
//鼠标移开时重设定时器 
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed);} 
</script> <div id="demo" style="overflow:hidden;"> 
<div id="demo1"> 
<asp:DataList ID="DataList7" runat="server" DataSourceID="SqlDataSource8" Style="border-right: #cccccc 1px solid;
border-top: #cccccc 1px solid; border-left: #cccccc 1px solid; border-bottom: #cccccc 1px solid"
Width="100%">
<ItemTemplate>
<table style="width: 100%">
<tr>
<td>
 <asp:Image ID="Image1" runat="server" ImageUrl="~/images/sign1.gif" />
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Eval("nid","newsdetail.aspx?id={0}") %>'
Text='<%# Eval("newtitle").ToString().Length > 10? Eval("newtitle").ToString().Substring(0, 10):Eval("newtitle") %>'></asp:HyperLink>
</td>
</tr>
<tr>
<td style="height: 1px">
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div> 
<div id="demo2"></div> 
</div> 
</td>
</tr>
</table>
<script type="text/javascript"> 
var speed=30;
demo2.innerHTML=demo1.innerHTML;//克隆demo1为demo2 
function Marquee(){ 
//当滚动至demo1与demo2交界时 
if(demo2.offsetTop-demo.scrollTop<=0) 
demo.scrollTop-=demo1.offsetHeight; //demo跳到最顶端 
else{ 
demo.scrollTop++;


var MyMar=setInterval(Marquee,speed);//设置定时器 
//鼠标移上时清除定时器达到滚动停止的目的 
demo.onmouseover=function() {clearInterval(MyMar);} 
//鼠标移开时重设定时器 
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed);} 
</script> 


看下这段代码有什么问题,怎么滚动不起来 --------------------编程问答--------------------

<!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>
    <title>无标题页</title>
    <style type="text/css">
        #demo{overflow:hidden;width: 300px;height: 20px;}
#demo1{text-align:center;width: 300px;}
#demo2{text-align:center;width: 300px;}
    </style>
</head>
<body>
<div id="demo">
                    <div id="indemo">
                        <div id="demo1">
                            <a>F1最年轻冠军</a> <a>米兰德比对决</a>
                            <a>高大宽出狱</a> <a>中国作家富豪</a>
    <a>广西列车脱轨</a> <a>京沪高铁贯</a>
                        </div>
                        <div id="demo2">
                        </div>
                    </div>
                </div>
                <script type="text/javascript">
        var speed=100;
        var tab = document.getElementById("demo");
        var tab1 = document.getElementById("demo1");
        var tab2 = document.getElementById("demo2");
        tab2.innerHTML = tab1.innerHTML;
        function Marquee()
        {                      
    if(tab2.offsetTop-tab.scrollTop<=0)
                tab.scrollTop-=tab2.offsetTop;
            else{
                tab.scrollTop++;    
            }
  }
        var Mar = setInterval(Marquee,speed);
        tab.onmouseover=function(){clearInterval(Mar);}
        tab.onmouseout = function(){Mar = setInterval(Marquee,speed);}
    </script>
</body>
</html>

--------------------编程问答-------------------- --------------------编程问答-------------------- 你有资格说别人?就你这态度,难怪开了三帖没人回= =!悲剧
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,