<img src="" name="showIMG">
<script language="javascript">
with(document.images("showIMG")){
  if(height>300)
    height=300;
  if(width>300)
    width=300;
}
</script>