<script language="javascript">
var flag=false;
function DrawImage(ImgD){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>=500/400){
if(image.width>500){
ImgD.width=500;
ImgD.height=(image.height*400)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>400){
ImgD.height=400;
ImgD.width=(image.width*400)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script> <%if trim(rs2("bookpic"))<>"" then%>
<img src="<%=trim(rs2("bookpic"))%>" onload="javascript:DrawImage(this);" border=0 alt=欢迎发表评论>
<%else%>
<img src=images/emptybook.gif width=200 height=160 alt="">
<%end if%>
我要实现从数据库中读取一张图片显示出来后
我选择一种图片框,让图片图刚好和显示出来的图片一样大
现在要解决怎 样让图片框和显示出来的图片配套。
就是这个网站一样:
http://www.kenduncan.com/show_prod.php?id=1215&cat_id=242&sub_cat_id=253
点一下,下面的radio就出来一个图片框,刚好和图片配套
图片是动态出来的,而且大小不一样
<INPUT name=frame
onclick="MM_swapImage('Frame','','/images/depImages/119.gif',0);check_set()"
type=radio>
怎样设它的相对大小呢?
那么在MM_swapImage里加上设置图片框大小的语句
请贴出显示图片的代码及MM_swapImage的代码
MM_swapImage是一个交换图象函数
dreamweaver自动生成的
<INPUT name=frame
onclick="MM_swapImage('Frame','','/images/depImages/119.gif',0);check_set()"
type=radio>
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
就是让这个框的大小随着图片的大小改变而改变
图片是从数据库中取得的
帮帮忙!!
看一下是怎么回事。