0

我对 jCrop 有疑问。他在其他浏览器中运行,但在 IE8 中不工作。我找不到问题。如果是图片数据问题或者图片大小不允许裁剪。有人可以帮忙吗??

<script type="text/javascript">

    jQuery(document).ready(function () {

    // Create variables (in this scope) to hold the API and image size
       var jcrop_api, boundx, boundy;
       var $targetImage = jQuery('.targetImage'), targetImageDOM = $targetImage[0];

       var carregarJcrop = function () {
           $targetImage.Jcrop({
           onChange: updatePreview,
           onSelect: updatePreview,
           aspectRatio: 1
           }, function () {
   // Use the API to get the real image size
           var bounds = this.getBounds();
           boundx = bounds[0];
           boundy = bounds[1];
      // Store the API in the jcrop_api variable
           jcrop_api = this;
              });
           function updatePreview(c) {
            if (parseInt(c.w) > 0) {

               var rx = 231 / c.w;
               var ry = 231 / c.h;

               jQuery('#x').val(c.x);
               jQuery('#y').val(c.y);
               jQuery('#w').val(c.w);
               jQuery('#h').val(c.h);



           jQuery('.jcrop-preview').css({
               width: Math.round(rx * boundx) + 'px',
               height: Math.round(ry * boundy) + 'px',
               marginLeft: '-' + Math.round(rx * c.x) + 'px',
               marginTop: '-' + Math.round(ry * c.y) + 'px'
                                                    });
                                                }
                                            };
                                        };

               var checaCarregamento = function () {
                   if (targetImageDOM.complete) {
                       carregarJcrop()
                   } else {
                   setTimeout(checaCarregamento, 500);
                     }
                   };

                   if ($targetImage.length > 0)
                      setTimeout(checaCarregamento, 500);
                         });

4

1 回答 1

0

你用的是最新版本吗?似乎有一个 IE8 修复:

IE 8 修复

于 2013-05-09T17:46:41.250 回答