要在页面显示的图片的标签 为
<img src='" + s_pic2.InnerXml.ToString() + "' width=\"500px\" height=\"300px\"/>"
其中 s_pic2.InnerXml.ToString() 为通过webservice 获取的 图片的 http地址 ,这样获取的图片有的大有的小我想让它大于 500*300时 以 500*300 显示,小于 500*300时 则原样显示 ,控制方法最好就写在 img 标签里
<img src='" + s_pic2.InnerXml.ToString() + "' width=\"500px\" height=\"300px\"/>"
其中 s_pic2.InnerXml.ToString() 为通过webservice 获取的 图片的 http地址 ,这样获取的图片有的大有的小我想让它大于 500*300时 以 500*300 显示,小于 500*300时 则原样显示 ,控制方法最好就写在 img 标签里
function test(obj) {
if (obj.width >= 500) {
obj.width = 500;
obj.height = 300;
}
}
楼主先做一下我给你静态的!,然后在做动态的!!
if (obj.width >= 500) {
obj.width = 500;
obj.height = 300;
}
}<script>
也要写到数据库里吗
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>= 140/120){
if(image.width>140){
ImgD.width=140;
ImgD.height=(image.height*140)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>120){
ImgD.height=120;
ImgD.width=(image.width*120)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script>
onload="javascript:DrawImage1(this)">
使用地址获取图片,缩略图