隨筆-153  評論-235  文章-19  trackbacks-0
               收集于網(wǎng)絡(luò),自已小改動下。
          有DrawImage(ImgD, width, height) 調(diào)整圖像比例的javascript函數(shù)。

          <script language="javascript">
          <!--

          var flag=false;
          function DrawImage(ImgD, width, height){
          var image=new Image();
          var iwidth = width;
          var iheight = height;
          image.src
          =ImgD.src;
          if(image.width>0 && image.height>0){
          flag
          =true;
          if(image.width/image.height>= iwidth/iheight){
          if(image.width>iwidth){
          ImgD.width
          =iwidth;
          ImgD.height
          =(image.height*iwidth)/image.width;
          }
          else{
          ImgD.width
          =image.width;
          ImgD.height
          =image.height;
          }
          ImgD.alt
          =image.width+""+image.height;
          }
          else{
          if(image.height>iheight){
          ImgD.height
          =iheight;
          ImgD.width
          =(image.width*iheight)/image.height;
          }
          else{
          ImgD.width
          =image.width;
          ImgD.height
          =image.height;
          }
          ImgD.alt
          =image.width+""+image.height;
          }
          }
          }
          //-->
          </script>
          <style type="text/css">
          .pic_size 
          {border:1px solid #CCCCCC;width:240px;height:200px;margin-top:5px;background:#FFF;}
          </style>
          <div class="pic_size"><table width="100%" height="100%"><tr><td style="text-align: center;vertical-align: middle;"><img src="my.jpg" onload = "DrawImage(this,240,200)"></td></tr></table></div>
          posted on 2008-03-16 12:43 流浪汗 閱讀(379) 評論(0)  編輯  收藏 所屬分類: HTML

           
          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          留言簿(14)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          新聞分類

          新聞檔案

          收藏夾

          友情鏈接

          同學(xué)鏈接

          學(xué)習(xí)鏈接

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 560399
          • 排名 - 86

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 东乌| 寿宁县| 河津市| 都昌县| 万安县| 曲靖市| 辽阳市| 屏山县| 大埔区| 左云县| 泰顺县| 遂昌县| 南陵县| 闻喜县| 赞皇县| 南郑县| 泸水县| 浦县| 霞浦县| 漳浦县| 南靖县| 宁晋县| 凤庆县| 绥宁县| 环江| 安康市| 双牌县| 花莲市| 宁都县| 株洲市| 论坛| 宿迁市| 璧山县| 云林县| 濮阳县| 广水市| 邻水| 武穴市| 华池县| 武乡县| 谷城县|