当前位置:编程学习 > asp >>

asp 问题 从数据库中取出的图片,如何滚动?

答案:<div id=demo style="OVERFLOW: hidden; WIDTH: 970px; HEIGHT: 132px" >
<table width="970" border=0 align=center cellpadding=0 cellspacing="0" cellspace="0">
<tbody>
  <tr>
 <td width="74%" height="82" valign=top  id=demo1 onMouseMove="this.bgColor='#FCD41C'" onMouseOut="this.bgColor='#FF9900'">
<table  border="0" cellpadding="0" cellspacing="0">
  <tr align="center"><%
set rs=server.CreateObject("adodb.Recordset")
sql="select * from pic order by id desc "
rs.open sql,conn,1,1
do while not rs.eof%> 
   <td bgcolor="#bfe0f3" valign="top">
    <table border="0" cellpadding="0" cellspacing="0" style="border:1px #bfe0f3 solid" width="100%">
    <tr>
    <td height="100" align="center"  valign="top" bgcolor="#e5f4fb">
    <a href=>    </tr>
    </table>
    <table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" style="font-weight:bold; font-size:12px; color:#000"><%=rs("picname")%></td>
    </tr>
    </table>
   </td>
   <%    
   rs.movenext
   loop
   rs.close
   set rs=nothing
   %> 
  </tr>
</table>
</td>
<td width="2%" valign=top id=demo2 bgcolor="#DE5552"></td>
</tr>
</tbody>
</table>
</div>
<SCRIPT>
var speed=10
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>

<TABLE width=900 height="40" border=0 align="center" cellPadding=0 cellSpacing=0>
  <TBODY>
  <TR>
    <TD valign="middle" bgcolor="#FFFFFF">
      <div id=demo style="overflow:hidden;height:40px;width:900px;">
  <table border="0" cellspacing="0" cellpadding="0" width="898">
  <tr>
  <td width="603" height="40" align="left" valign="middle" id=demo1> 
  <!--第二个表-->
  <table border="0" cellpadding="0" cellspacing="0">
  <% dim i %>
  <tr>
   <%
strsql="select * from FriendSite where LinkType=1 order by ID desc"
set rs=server.createobject("ADODB.recordset")
rs.open strsql,conn,3,2
do until rs.eof
%>   
  <td>
  <table  border="0" cellpadding="0" cellspacing="0"><!--显示照片-->
                  <tr>
                    <td width="110" align="center">
     <div id="photo"><a href=>                  </tr>
                </table>
  </td>
  <%
rs.movenext
loop
i=i+1
if i mod 6=0 then
%>

  </tr>
  <%
  end if
rs.close 
%>
  </table>
  <!--第二个表结束-->  </td>
  <td width="295" id=demo2></td>
  </tr>
  </table>
  </div>  
  <!--第一个表结束-->
      <script language="javascript">
  var speed=10
  demo2.innerHTML=demo1.innerHTML
  demo.scrollLeft=demo.scrollWidth
    function Marquee()
   {
   if(demo.scrollLeft<=0)
    demo.scrollLeft+=demo2.offsetWidth
   else{
     demo.scrollLeft--
        }
   }
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function(){clearInterval(MyMar)}
demo.onmouseout=function(){MyMar=setInterval(Marquee,speed)}
</script>
   </TD>
</TR></TBODY></TABLE></BODY></HTML>
<%
conn.close
%>

JAVASCRIPT实现的

<SCRIPT. language=JavaScript>                      
[?#H)Z om.[0function marquee1()                      
j?5bQ2r{ D0{                      
1@)u~&`*L!?g9M_0    document.write("<div style='width:100%;overflow:hidden;' id=marquee nmouseover=clearInterval(repeat)    nmouseout=repeat=setInterval(scrollMarquee,1)>")                      
R+e_bJv%^2Xg:{0}                      
kpX(g,csYP0function marquee2()                      创意空间.zN}9_'L~!L3S
{                创意空间(}l8Rr8GHBn B
    document.write("</div>")   
{Rh u?8I U|0    marquee.childNodes[0].align='left';创意空间4B on\N)nW
创意空间Ws,~.p,LB
    if(marquee.childNodes[0].offsetWidth>marquee.offsetWidth) {
6caaxf hPV R0     marquee.appendChild(marquee.childNodes[0].cloneNode(true));
Fo YR n0     }
DQs^F0    else {创意空间Un!z"lI
     for(var i=0;i<Math.round(marquee.offsetWidth/marquee.childNodes[0].offsetWidth)+1;i++) {
,NK3yY+kdU0      marquee.appendChild(marquee.childNodes[0].cloneNode(true));
-cL:P1t(@ @"{1s0      }创意空间Y+H[6E#h
     }创意空间&e_[yv3_
    repeat=setInterval(scrollMarquee,1);创意空间 WT5c3r e0h8zA
}                      
N$J"a[/Wg0function scrollMarquee() {
'y!o@e)Uk'BT0if(marquee.scrollLeft<marquee.childNodes[0].offsetWidth)
9kg Rp4GI0    marquee.scrollLeft++;

上一个:Asp.net中如何防止用户多次登录?
下一个:有什么好方法来防御黑客对asp网站的攻击

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,