Jones: Bildervorschau: maximale Bildgrösse bestimmen

Beitrag lesen

Sers,

hier ich hab mal etwas zusammengestellt:

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>

<script language="javascript">
var maxSize=50;
img=new Image();
var bilder = new Array(
 "1.gif",
 "2.gif",
 "3.gif"
);

function showThumbs(){
 var str="";
 for(var i=0;i<bilder.length;i++){
  img.src=bilder[i];
  var tobig=(img.width > maxSize || img.height > maxSize)?true:false;
  var width=(tobig)?maxSize:img.height;
  var height=(tobig)?maxSize:img.height;

str+='<img src="'+img.src+'" width="'+width+'" height="'+height+'">';
 }

alert(str);

document.open();
 document.write(str);
 document.close();
}

</script>

</head>

<body>
<script language="JavaScript">
<!--
showThumbs();
//-->
</script>
</body>
</html>

Jones
----+