자동이미지크기조절 정보
javascript 자동이미지크기조절본문
<script language='javascript'>
function a(name){
w = eval("document."+name+".width");
h = eval("document."+name+".height");
maxWidth = 300; // 출력 최대이미지 가로. 이곳의 숫자를 고치세요.
maxHeight = 300; // 출력 최대 이미지 세로 . 이곳의 숫자를 고치세요.
if(w > maxWidth || h > maxHeight){
if(w > h){
nw = maxWidth;
nh = Math.round((h*nw)/w);
}else{
nh = maxHeight;
nw = Math.round((nh*w)/h);
}
}else{
nw = w;
nh = h;
}
eval("document."+name+".height="+nh);
eval("document."+name+".width="+nw);
}
</script>
<img src='http://www.happycgi.com/Attach/screen_shot/2004/08/13/b-1092371586-happycgi.jpg' name='aaaa' id='aaaa' onload='a("aaaa")'>
function a(name){
w = eval("document."+name+".width");
h = eval("document."+name+".height");
maxWidth = 300; // 출력 최대이미지 가로. 이곳의 숫자를 고치세요.
maxHeight = 300; // 출력 최대 이미지 세로 . 이곳의 숫자를 고치세요.
if(w > maxWidth || h > maxHeight){
if(w > h){
nw = maxWidth;
nh = Math.round((h*nw)/w);
}else{
nh = maxHeight;
nw = Math.round((nh*w)/h);
}
}else{
nw = w;
nh = h;
}
eval("document."+name+".height="+nh);
eval("document."+name+".width="+nw);
}
</script>
<img src='http://www.happycgi.com/Attach/screen_shot/2004/08/13/b-1092371586-happycgi.jpg' name='aaaa' id='aaaa' onload='a("aaaa")'>
추천
0
0
댓글 전체
특이한 스크립트군요.........^^