Features
-------------------------------------------------------------------------- | ||
| ||
下載: Download (密碼: 見壓縮檔註解) | ||
By dowloading you accept our Terms & Disclaimer. |
Instructions: |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> <script> //圖片縮圖 $(window).load(function(){ $("img").each(function(i){ if($(this).attr("alumb")=="true"){ //移除目前設定的影像長寬 $(this).removeAttr('width'); $(this).removeAttr('height'); //取得影像實際的長寬 var imgW = $(this).width(); var imgH = $(this).height(); //計算縮放比例 var w=$(this).attr("_w")/imgW; var h=$(this).attr("_h")/imgH; var pre=1; if(w>h){ pre=h; }else{ pre=w; } if(w>1 || h>1){pre=1;} //設定目前的縮放比例 $(this).width(imgW*pre); $(this).height(imgH*pre); } }); }); </script> <img src="sample.jpg" alumb="true" _w="300" _h="300" width="500"/>
|
|
0 留言:
發佈留言
您使用留言則表示同意及遵守使用條款及守則。
建議: 為方便留言回覆,請不要用匿名方式 留言。