asp.net实现滚动效果,图片是由数据库或者文件夹中读取静态的JavaScript实现方法:
index.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="Copyright" content="爱JavaScript中文网 http://www.ijavascript.cn/" />
<meta name="description" content="分享个人的JavaScript学习经历,做最好的JavaScript资料分享站点" />
<meta content="爱JavaScript中文网" name="keywords" />
<title>无缝滚动代码 - 爱JavaScript中文网</title>
<style type="text/css">
td {font-size: 12px;}
.opacity {COLOR: #4AAAC5; FILTER: alpha(opacity=100)}
.solid-top {BORDER-TOP: #CCCCCC 1px solid}
.solid-right {BORDER-RIGHT: #CCCCCC 1px solid}
.solid-bottom {BORDER-BOTTOM: #CCCCCC 1px solid}
.solid-left {BORDER-LEFT: #CCCCCC 1px solid}
</style>
</head><body>
<table width="510" border="0" align="center" cellpadding="0" cellspacing="0" class="solid-top solid-bottom">
  
  <tr>
    <td width="480"><iframe src="news-1.htm" name="new_date" 
                                width="480" marginwidth="0" height="150"
                                marginheight="0" scrolling="No" 
                                frameborder="0" id="new_date" border="0" framespacing="2" 
                                noresize="noresize" vspale="0"></iframe></td>
    <td width="30" align="center" valign="top"><br>
        <img src="images/scrollup.gif" alt="点住不放可以快速向上滚动" 
                                width="11" height="11" vspace="5" class="opacity" 
                                onMouseDown="movover();movstar(-3,2)" 
                                onMouseUp="movover();movstar(-1,20)" 
                                onMouseOver="movstar(-1,20);o_down(this)" 
                                onMouseOut="movover();o_up(this)" /><br>
        <img src="images/scrolldw.gif" alt="点住不放可以快速向下滚动" 
                                width="11" height="11" vspace="5" class="opacity" 
                                onMouseDown="movover();movstar(3,2)" 
                                onMouseUp="movover();movstar(1,20)" 
                                onMouseOver="movstar(1,20);o_down(this)" 
                                onMouseOut="movover();o_up(this)" /> <br>
    <script language=JavaScript>
function movstar(a,time){
movx=setInterval("mov("+a+")",time)
}
function movover(){
clearInterval(movx)
}
function mov(a){
scrollx=new_date.document.body.scrollLeft
scrolly=new_date.document.body.scrollTop
scrolly=scrolly+a
new_date.window.scroll(scrollx,scrolly)
}
function o_down(theobject){
object=theobject
while(object.filters.alpha.opacity>60){
object.filters.alpha.opacity+=-10}
}
function o_up(theobject){
object=theobject
while(object.filters.alpha.opacity<100){
object.filters.alpha.opacity+=10}
}
function wback(){
if(new_date.history.length==0){window.history.back()}
else{new_date.history.back()}
}
        </script></td>
  </tr>
</table>
<br>
<br>
<table width="510" height="180" border="0" align="center" cellpadding="0" cellspacing="0" class="solid-left solid-right">
  <tr>
    <td><iframe src="news-2.htm" name="frm_piclist" 
                                width="510" marginwidth="0" height="150"
                                marginheight="0" scrolling="No" 
                                frameborder="0" id="frm_piclist" border="0" framespacing="2" 
                                noresize="noresize" vspale="0"></iframe></td>
  </tr>
  <tr>
    <td height="30" align="center"><IMG 
                  src="images/scrolllf.gif" alt="点住不放可以快速向左滚动" width="11" height="11" hspace="5" border=0 class=opacity 
                  onmousedown=runover();runstar(-3,2,2) 
                  onmouseup=runover();runstar(-1,20,2) 
                  onmouseover=runstar(-1,20,2);x_down(this) 
                  onmouseout=runover();x_up(this)><IMG 
                  src="images/scrollrt.gif" alt="点住不放可以快速向右滚动" width="11" height="11" hspace="5" border=0 class=opacity 
                  onmousedown=runover();runstar(3,2,2) 
                  onmouseup=runover();runstar(1,20,2) 
                  onmouseover=runstar(1,20,2);x_down(this) 
                  onmouseout=runover();x_up(this)>
    <SCRIPT>
function runstar(a,time,flag){
if (1 == flag){runx=setInterval("run("+a+")",10)}
else{runx=setInterval("run2("+a+")",10)}}
function runover(){
clearInterval(runx)
}
function run(a){
scrollx=frm_frdlist.document.body.scrollLeft
scrolly=frm_frdlist.document.body.scrollTop
scrollx=scrollx+a
frm_frdlist.window.scroll(scrollx,scrolly)
}
function run2(a){
scrollx=frm_piclist.document.body.scrollLeft
scrolly=frm_piclist.document.body.scrollTop
scrollx=scrollx+a
frm_piclist.window.scroll(scrollx,scrolly)
}
function x_down(theobject){
object=theobject

while(object.filters.alpha.opacity>60){
object.filters.alpha.opacity+=-10
}
}
function x_up(theobject){
object=theobject
while(object.filters.alpha.opacity<60){
object.filters.alpha.opacity+=10
}
}
function wback(){
if(frm_frdlist.history.length==0){window.history.back()}
else{frm_frdlist.history.back()}
}
      </SCRIPT></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
news-2.html:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="Copyright" content="爱JavaScript中文网 http://www.ijavascript.cn/" />
<meta name="description" content="分享个人的JavaScript学习经历,做最好的JavaScript资料分享站点" />
<meta content="爱JavaScript中文网" name="keywords" />
<title>爱JavaScript中文网</title>
<style type="text/css">
td {font-size: 12px;}
</style>
</head><body>
<table width="724" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="196" height="132" align="center"><a href="http://www.prisonbreakdvd.com/" target="_blank"><img src="images/coolsite01.jpg" width="168" height="120" border="0" /></a></td>
    <td width="196" align="center"><a href="http://www.egolounge.de/" target="_blank"><img src="images/coolsite02.jpg" width="168" height="120" border="0" /></a></td>
    <td width="196" height="132" align="center"><a href="http://www.cocoonmultimedia.com/" target="_blank"><img src="images/coolsite03.jpg" width="168" height="120" border="0" /></a></td>
    <td width="196" align="center"><a href="http://www.flowersforhope.com/" target="_blank"><img src="images/coolsite04.jpg" width="168" height="120" border="0" /></a></td>
  </tr>
  <tr>
    <td width="196" height="20" align="center"><a href="http://www.prisonbreakdvd.com/" target="_blank">Prison Break</a></td>
    <td width="196" height="20" align="center"><a href="http://www.egolounge.de/" target="_blank">EGOLOUNGE</a></td>
    <td width="196" height="20" align="center"><a href="http://www.cocoonmultimedia.com/" target="_blank">Merijn Straathof</a></td>
    <td width="196" height="20" align="center"><a href="http://www.flowersforhope.com/" target="_blank">Hope Garden</a></a></td>
  </tr>
</table>
</body>
</html>主要我不清楚asp.net怎么实现在现有角本文件本嵌入代码,希望有哪位高手能够帮助我 。
应该这个问题不难,但我没有好好看过asp的书。。
回去应该好好看看书了, 不能直接看代码了。

解决方案 »

  1.   


    news-1.html:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="Copyright" content="爱JavaScript中文网 http://www.ijavascript.cn/" />
    <meta name="description" content="分享个人的JavaScript学习经历,做最好的JavaScript资料分享站点" />
    <meta content="爱JavaScript中文网" name="keywords" />
    <title>爱JavaScript中文网</title>
    <style type="text/css">
    td {font-size: 12px;}
    </style>
    </head><body>
    <table width="410" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="22" align="left"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span><span class="green">[10-09] 本站新增 Mini Pixel Icons 专题。</span></td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span><span class="green">[10-08] 壁纸更新至30张。</span></td>
      </tr>
      <tr>
        <td height="22" align="left"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span><span class="green">[09-27]</span> 本站新增3个经典导航资源 <a href="code.asp"></a></td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span><span class="green">[09-26]</span> 新增flash播放器专题<span class="green">。</span><a href="code.asp"></a></td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" />[09-16] 本站新增资源更新订阅服务,欢迎大家订阅。</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[09-15] 新增100x300对联广告专题,广告需要创意。</td>
      </tr>
      <tr>
        <td width="356" height="22" align="left" class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" />[09-10] 懒人图库改版首页,以便大家更容易找到下载链接。</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[09-05] 新增网页标准专题,源码仅供学习研究,请勿用于商业用途。</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[09-01] 广告代码更新至28,新增Lightbox和产品图片展示代码。</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[08-22] 新增flash导航菜单专题,经典实用!</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[08-15] PNG透明图标已经更新到1800张,下载地址见首页右侧。</td>
      </tr>
      <tr>
        <td height="22" align="left" class="dashed-bottom"><span class="dashed-bottom green"><img src="images/arrow.gif" width="12" height="16" hspace="5" align="absmiddle" /></span>[08-06] 精选300张QQ表情图片,让你的表情丰富起来吧~</td>
      </tr>
    </table>
    </body>
    </html>
      

  2.   

    <%
    %>
    变量<%=str%>
    public string str{get;set;}
      

  3.   

    table width=98% border=0 cellpadding=0 cellspacing=0>
    <tr><td bgcolor=#333333 align=center> 
        <table width=600 border=0 cellpadding=0 cellspacing=0> 
        <tr><td style="padding-top:6px"> 
         <div id=demo style=overflow:hidden;height:120;width:600px;color:#ffffff>
         <table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1>
                <table><tr>
            <td><img src="images/ye4.jpg" height="122"></td>
            <td width=8></td>
            <td><img src="images/ye6.jpg" height="122"></td>
            <td width=8></td>
            <td><img src="images/ye5.jpg" height="122"></td></tr></table>
        </td><td id=demo2></td></tr></table></div>
    <script>
    var speed=10//速度数值越大速度越慢
    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>
        </td></tr> 
        </table> 
    </td></tr> 
    </table> 
    代码中的<img src="images/ye4.jpg" height="122">
    用<img src=<%=str %> height="122">
    str是从数据库中取出来的
    SRC地址。
      

  4.   

    谢谢
    但是从数据库读来的图片的路径信息是N个
    怎么样才能生成table呢?
    要生成table肯定得用到for循环,但是我不知道这个循环应该怎么写
    希望再次指点,谢谢你。
      

  5.   

    但是从数据库读来的图片的路径信息是N个
    怎么样才能生成table呢?使用GridView,Repeater,Datalist控件都可以啊
      

  6.   

    自己的事还得自己完成:
    <div id="List1_1">
                        <%=imagex%>
     </div>我用这种方法来实现了。不知道这是不是个笨方法 // 产品滚动
            DB db = new DB();        DataTable dt = db.GetDatatable("select * from coalproduct");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string imageName = dt.Rows[i]["imageName"].ToString();
                string title = dt.Rows[i]["title"].ToString();
                string idStr = dt.Rows[i]["id"].ToString();
                imagex += string.Format("<a class=\"pl\" href=\"news_more.aspx?cid={0}\" target=\"_blank\"> <img height=\"72\" alt=\"{1}\" src=\"images/{2} \" width=\"96\">{3}</a> "
                    , idStr, title, imageName, title);
            }
    过年了大家都开心,分都没有人要了!