下午做了一个asp+js实现图片的轮显的效果,效果图如:http://www.dwww.cn 左侧的图片轮显,在http://www.dwww.cn 我用的是js,然后我改了一下用asp实现效果的。
pic.asp源代码:
<% '连接数据库代码省去了 sql=("select * from Pic order by picorder asc,id desc") Set rs=server.CreateObject("adodb.recordset") If rs.eof And rs.bof Then %> document.write('暂无图片'); <% Else %>
var focus_width=820 var focus_height=185 var text_height=0 var swf_height = focus_height+text_height
<% '转载请保留来源 http://www.dwww.cn Do While Not rs.eof pics=pics&rs("picurl")&"|" '把图片用"|"连接起来 links=links&rs("picaddress")&"|" rs.movenext Loop
picLen=Len(pics) pics=Left(pics,(picLen-1)) '作用是去除最后一个"|"
linksLen=Len(links) links=Left(links,(linksLen-1))
%> var pics='<%=pics%>' var links='<%=links%>' var texts=''
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="flash/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">'); 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="flash/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#ffffff" 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>');
<%End If %>
然后在首页调用的地方,<script type="text/javascript" src="pic.asp"></script>
Flash文件下载:pixviewer.swf |