<% pathlevel="../" %> <!--#include file="../data/conn.asp"--> <%-----------------数据库连接 '幻灯片新闻 sql="select top 5 * from [图表专区] where 属于=5 and 类别=1 order by 编号 desc" set rs=server.createobject("adodb.recordset") rs.open sql,cn,1,1 if not rs.eof then -------------------读取数据库内容 -----------------下面是对读取的内容进行处理 k=1 Num_total=rs.recordcount for i=1 to 5 if i>Num_total then exit for if i=1 then imgUrl11=rs("图片") if len(rs("标题"))>=18 then imgtext11= left(rs("标题"),18)&"..." else imgtext11=rs("标题") end if imgLink11=rs("图片") end if if i=2 then imgUrl22=rs("图片") if len(rs("标题"))>=18 then imgtext22= left(rs("标题"),18)&"..." else imgtext22=rs("标题") end if imgLink22=rs("图片") end if if i=3 then imgUrl33=rs("图片") if len(rs("标题"))>=18 then imgtext33= left(rs("标题"),18)&"..." else imgtext33=rs("标题") end if imgLink33=rs("图片") end if if i=4 then imgUrl44=rs("图片") if len(rs("标题"))>=18 then imgtext44= left(rs("标题"),18)&"..." else imgtext44=rs("标题") end if imgLink44=rs("图片") end if if i=5 then imgUrl55=rs("图片") if len(rs("标题"))>=18 then imgtext55= left(rs("标题"),18)&"..." else imgtext55=rs("标题") end if imgLink55=rs("图片") end if rs.movenext k=k+1 next %> ----------------有数据的时候调用flash显示图片 <a target=_self href="javascript:goUrl()"> <span class="f14b"> <script type="text/javascript"> imgUrl1="<%=imgUrl11%>"; imgtext1="<%=imgtext11%>" imgLink1=escape("<%=imgLink11%>"); imgUrl2="<%=imgUrl22%>"; imgtext2="<%=imgtext22%>" imgLink2=escape("<%=imgLink22%>"); imgUrl3="<%=imgUrl33%>"; imgtext3="<%=imgtext33%>" imgLink3=escape("<%=imgLink33%>"); imgUrl4="<%=imgUrl44%>"; imgtext4="<%=imgtext44%>" imgLink4=escape("<%=imgLink44%>"); imgUrl5="<%=imgUrl55%>"; imgtext5="<%=imgtext55%>" imgLink5=escape("<%=imgLink55%>"); var focus_width=246 var focus_height=142 var text_height=15 var swf_height = focus_height+text_height <%if Num_total=1 then%> var pics=imgUrl1 var links=imgLink1 var texts=imgtext1 <%elseif Num_total=2 then%> var pics=imgUrl1+"|"+imgUrl2 var links=imgLink1+"|"+imgLink2 var texts=imgtext1+"|"+imgtext2 <%elseif Num_total=3 then%> var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3 var links=imgLink1+"|"+imgLink2+"|"+imgLink3 var texts=imgtext1+"|"+imgtext2+"|"+imgtext3 <%elseif Num_total=4 then%> var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4 var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4 var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4 <%elseif Num_total=5 then%> var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5 var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5 var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5 <%end if%> document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">'); document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">'); document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">'); document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>'); document.write('</object>'); </script> </span> </a> <span id=focustext class=f14b> </span> ----------------------没有数据直接输出 <% else response.Write "暂时没有数据!" end if %>
把上面的文件保存在一个文件show.asp内在需要的地方直接调用就可以了。。
这样就不会出现页面显示混乱的问题了。。。需要一个显示图片的flash。
下面贴一个js+div 显示的。
<% pathlevel="../" %> <!--#include file="../data/conn.asp"--> <Script Language="JavaScript"> <!-- function SlidePic(ID) ...{ this.ID=ID; this.Width=0; this.Height=0; this.TimeOut=5000; this.Effect=23; this.TitleLen=0; this.PicNum=-1; this.Img=null; this.Url=null; this.Title=null; this.AllPic=new Array(); this.Add=AddSlidePic; this.Show=ShowSlidePic; this.LoopShow=LoopShowSlidePic; } function NewSlide() ...{ this.ImgUrl=""; this.LinkUrl=""; this.Title=""; } function AddSlidePic(SP) ...{ this.AllPic[this.AllPic.length] = SP; } function ShowSlidePic() ...{ if(this.AllPic[0] ==null) returnfalse; document.write('<div align="center"><a id="Url'+this.ID +'" href="" target=_blank><img id="Img'+this.ID +'" style="width:'+this.Width +'; height:'+this.Height +'; filter: revealTrans(duration=2,transition=23);" src="javascript:null" border="0"></a>'); if(this.TitleLen !=0) document.write("<br><Div id='Title"+this.ID +"'></Div></div>"); this.Img = document.getElementById("Img"+this.ID); this.Url = document.getElementById("Url"+this.ID); this.Title = document.getElementById("Title"+this.ID); this.LoopShow(); } function LoopShowSlidePic() ...{ if(this.PicNum<this.AllPic.length-1) this.PicNum++ ; elsethis.PicNum=0; this.Img.filters.revealTrans.Transition=this.Effect; this.Img.filters.revealTrans.apply(); this.Img.src=this.AllPic[this.PicNum].ImgUrl; this.Img.filters.revealTrans.play(); this.Url.href=this.AllPic[this.PicNum].LinkUrl; if(this.Title) this.Title.innerHTML='<a href="'+this.AllPic[this.PicNum].LinkUrl+'" >'+this.AllPic[this.PicNum].Title+'</a>'; this.Img.timer=setTimeout(this.ID+".LoopShow()",this.TimeOut); } var SlidePic =new SlidePic("SlidePic"); SlidePic.Width =150; //图片宽度 SlidePic.Height =120; //图片高度 SlidePic.TimeOut =5000; //延迟时间 SlidePic.Effect =23; SlidePic.TitleLen =1; <% '幻灯片新闻 sql="select top 3 * from 图表专区 where 属于=16 and 类别=2 order by 编号 desc" //数据库字段 set rs=server.createobject("adodb.recordset") rs.open sql,cn,1,1 if not rs.eof then k=1 Num_total=rs.recordcount for i=1 to Num_total %> var NewItem = new NewSlide(); NewItem.ImgUrl = '<%=rs("图片")%>'; //图片地址 NewItem.LinkUrl= '<%=rs("图片")%>'; //链接地址 NewItem.Title = '<span><%=rs("标题")%></span>'; //新闻标题 SlidePic.Add(NewItem); <% rs.movenext k=k+1 'loop next else response.write "暂无图片新闻" end if %> SlidePic.Show(); //--> </Script>