Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall
Control picture scaling code in the page network, in general, it is very difficult to do this, because the small map from the database call out when the small, and when the call of the picture is high-definition digital photos, you know that there are many headaches, completely tabel squeezed not like a human face, all squeezed broken, ugly to see people ah, To control the picture in a certain size scaling, I think of is using JavaScript, and finally written out, tested n many back before successful, please see the code:
The front page plus (note that JavaScript is case-sensitive, I do not like the least of him, you do not have to pay attention to, I have written a test finished before issued to share, direct replication is not a problem)
<script language= "JavaScript" >
<!--
//Picture scaled
var flag=false;
function DrawImage (IMGD) {
var image=new image ();
var iwidth = 480; Define allowable picture width
var iheight = 530; Define Allow picture height
image.src=imgd.src;
if (image.width>0 && image.height>0) {
flag=true;
if (image.width/image.height>= iwidth/iheight) {
if (image.width>iwidth) {
Imgd.width=iwidth;
imgd.height= (image.height*iwidth)/image.width;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "x" +image.height;
}
else{
if (image.height>iheight) {
Imgd.height=iheight;
imgd.width= (image.width*iheight)/image.height;
}else{
Imgd.width=image.width;
Imgd.height=image.height;
}
imgd.alt=image.width+ "x" +image.height;
}
}
}
//Call:
//-->
</script>
Show the picture in the body
<img src= "Picture call path. jpg" Border=0 >
OK, this is done, that whether small or large picture, you can only swim in the 480x530.
Testimonials: 8630.html "> Sometimes feel that writing a program is so happy, as if everything in the grip, because learned something." Who has the simpler, please share the technology!
This article originates from: Peace Alliance---ASP Technology Alliance area http://www.hp8858.com Reprint please keep the link, thank you.