웹프로그램
자바스크립트 이미지 리사이징 함수
세이박스
2008. 11. 7. 16:04
반응형
페이지를 모두 불러온후 이미지를 페이지 사이즈에 맞게 다시 조절해서 보여주게 하고 싶을때 다음과 같이 하시면됩니다.
function resizeImg(imgObj, width, height) {
if(imgObj.width>width){
imgObj.width = width;
}
if(height!=""){
if(imgObj.height>height){
imgObj.height = height;
}
}
}
if(imgObj.width>width){
imgObj.width = width;
}
if(height!=""){
if(imgObj.height>height){
imgObj.height = height;
}
}
}
<img src="" onLoad="javascript-x:resizeImg(this,520)" border="0">
반응형