滚动图片效果的问题 我的目的是想从数据库中读取图片,图片是以二进制保存到access中的.
滚动图片效果的问题我的目的是想从数据库中读取图片,图片是以二进制保存到access中的.然后动态的输出,出现滚动的效果.目前我的代码出现不显示图片,但是出现滚动的边框.具...
滚动图片效果的问题 我的目的是想从数据库中读取图片,图片是以二进制保存到access中的.然后动态的输出,出现滚动的效果.目前我的代码出现不显示图片,但是出现滚动的边框.
具体代码如下:
<!-- rs_Product("img")是图片地址, rs_Product("Photo_Name") 是产品名字-->
<style type="text/css">
div.image{background-color:#000000;}
div.scroll{margin:10px;width:550px;height:110px;overflow:hidden;background-color:#cccccc;}
div.scroll table{left:0px;width:100%;position:relative;}
div.scroll table td{white-space:nowrap;}
div.scroll table td img{height:100px;margin:0px 5px;border:0px;}
</style>
<div class="image">
<div class="scroll" onmouseover="clearInterval(timer);" onmouseout="timer = setInterval(play, 20);">
<table id="scroll_field"><tr><td>
<p>
<%
set rs_Product=server.createobject("adodb.recordset")
sqltext="select * from ImgData order by InTime desc"
rs_Product.open sqltext,conn,1,1
Do while Not rs_product.Eof
%>
<a href="../product/View.asp?ID=<%=rs_Product("ID")%>"><img src=<%=rs_Product("img")%> border=0 width="150" height="180" align="middle"></a><a href="../product/View.asp?ID=<%=rs_Product("ID")%>"><%=rs_Product("Photo_Name")%></a>
<!-- rs_Product("img")是图片路径, rs_Product("Photo_Name") 是产品名字-->
<%
rs_Product.MoveNext
row_count=row_count+1
Loop
rs_Product.close
%>
</p>
</td><td></td></tr></table>
</div>
<script type="text/javascript">
var timer = null;
var field = document.getElementById("scroll_field");
onload = function(){
field.getElementsByTagName("td")[1].innerHTML += field.getElementsByTagName("td")[0].innerHTML;
timer = setInterval(play, 20);
}
function play(){
var lf = 0;
if(!field.style.left){
field.style.left = "0px";
lf = 0;
}
else{
lf = parseInt(field.style.left);
}
try{
field.style.left = ((lf - 1) % (field.clientWidth / 2)) + "px";
}
catch(e){
field.left = ((l - 1) % (field.clientWidth / 2)) + "px";
}
}
</script>
</div> 展开
具体代码如下:
<!-- rs_Product("img")是图片地址, rs_Product("Photo_Name") 是产品名字-->
<style type="text/css">
div.image{background-color:#000000;}
div.scroll{margin:10px;width:550px;height:110px;overflow:hidden;background-color:#cccccc;}
div.scroll table{left:0px;width:100%;position:relative;}
div.scroll table td{white-space:nowrap;}
div.scroll table td img{height:100px;margin:0px 5px;border:0px;}
</style>
<div class="image">
<div class="scroll" onmouseover="clearInterval(timer);" onmouseout="timer = setInterval(play, 20);">
<table id="scroll_field"><tr><td>
<p>
<%
set rs_Product=server.createobject("adodb.recordset")
sqltext="select * from ImgData order by InTime desc"
rs_Product.open sqltext,conn,1,1
Do while Not rs_product.Eof
%>
<a href="../product/View.asp?ID=<%=rs_Product("ID")%>"><img src=<%=rs_Product("img")%> border=0 width="150" height="180" align="middle"></a><a href="../product/View.asp?ID=<%=rs_Product("ID")%>"><%=rs_Product("Photo_Name")%></a>
<!-- rs_Product("img")是图片路径, rs_Product("Photo_Name") 是产品名字-->
<%
rs_Product.MoveNext
row_count=row_count+1
Loop
rs_Product.close
%>
</p>
</td><td></td></tr></table>
</div>
<script type="text/javascript">
var timer = null;
var field = document.getElementById("scroll_field");
onload = function(){
field.getElementsByTagName("td")[1].innerHTML += field.getElementsByTagName("td")[0].innerHTML;
timer = setInterval(play, 20);
}
function play(){
var lf = 0;
if(!field.style.left){
field.style.left = "0px";
lf = 0;
}
else{
lf = parseInt(field.style.left);
}
try{
field.style.left = ((lf - 1) % (field.clientWidth / 2)) + "px";
}
catch(e){
field.left = ((l - 1) % (field.clientWidth / 2)) + "px";
}
}
</script>
</div> 展开
展开全部
显示从数据库中读取的二进制图片的代码如下,可以参考:
showimg.asp
<!--#include file="conn.asp" -->
<%
name=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset")
strsql="select * from userinfo where UserName=" & name
rs.open strsql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("Image").getChunk(7500000)
rs.close
set rs=nothing
set conn=nothing
%>
showimg.asp
<!--#include file="conn.asp" -->
<%
name=request.QueryString("id")
set rs=server.CreateObject("adodb.recordset")
strsql="select * from userinfo where UserName=" & name
rs.open strsql,conn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite rs("Image").getChunk(7500000)
rs.close
set rs=nothing
set conn=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询