더 나은 프로그래머가 되자

자바스크립트로 이미지 리사이징하기 본문

언어/js

자바스크립트로 이미지 리사이징하기

greathuman 2011. 11. 18. 18:33


<script language="javascript">
  function imgcheck(imgObj,bool){
    
   var imgWidth = 730;
  
   if (bool)
   {
            var O_Width = imgObj.width;
   var ReWidth = O_Width;
      if (ReWidth > imgWidth)
      {
     ReWidth = imgWidth;
      }

   imgObj.width = ReWidth;
  
   }
   else
   {
      imgObj.style.display = 'none';
   }

  }
</script>


<img src="이미지경로" onload="javascript:imgcheck(this,true);" onerror="javascript:imgcheck(this,false);">

Comments