function suotu(){ var size = 600; var objs = document.getElementsByTagName("img"); for(i=0;i<objs.length;i++){ if (objs[i].width > objs[i] .height) { if (objs[i].width > size) objs[i].width = size; } else { if (objs[i].height > size) objs[i].height = size; } } } </script>