画像をスケーリングし、パラメータを入力して初期サイズを設定できます
16993 ワード
サムネイルを生成せずに、そのまま元の図を呼び出します
1 <head>
2 <title> </title>
3 <script language="javascript" type="text/javascript">
4 // ,
5 function resizeimg(ImgD,iwidth,iheight) {
6 var image=new Image();
7 image.src=ImgD.src;
8 if(image.width>0 && image.height>0){
9 if(image.width/image.height>= iwidth/iheight){
10 if(image.width>iwidth){
11 ImgD.width=iwidth;
12 ImgD.height=(image.height*iwidth)/image.width;
13 }else{
14 ImgD.width=image.width;
15 ImgD.height=image.height;
16 }
17 ImgD.alt=image.width+"×"+image.height;
18 }
19 else{
20 if(image.height>iheight){
21 ImgD.height=iheight;
22 ImgD.width=(image.width*iheight)/image.height;
23 }else{
24 ImgD.width=image.width;
25 ImgD.height=image.height;
26 }
27 ImgD.alt=image.width+"×"+image.height;
28 }
29 ImgD.style.cursor= "pointer"; //
30 ImgD.onclick = function() { window.open(this.src);} //
31 if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { // , IE
32 ImgD.title = " , ";
33 ImgD.onmousewheel = function img_zoom() //
34 {
35 var zoom = parseInt(this.style.zoom, 10) || 100;
36 zoom += event.wheelDelta / 12;
37 if (zoom> 0) this.style.zoom = zoom + "%";
38 return false;
39 }
40 } else { // IE
41 ImgD.title = " ";
42 }
43 }
44 }
45 </script>
46 </head>
47 <body>
48 <br /><img onload="javascript:resizeimg(this,100,200)" src="http://img.poco.cn/photo/20060602/972374149620060602140117_1.jpg" />
49
50 </body>
51 </html>