2013-07-25 39 views
0

我正在使用JCrop在上傳後用Ajax上傳 控件在我的web應用程序中上傳圖像。它在Chrome,Firefox上效果很好,但不是IE瀏覽器中的 。我使用JCrop v0.9.12(版本:20130202)和IE v10.0.9.9200.16635。問題是JCrop選擇在IE中不起作用。 謝謝!JCrop在IE的圖像問題上的選擇

這是我的腳本。

<script type="text/javascript"> 

    jQuery(document).ready 
     (function ($) { 
      // To hold the API and image size. 
     var jcrop_api, boundx, boundy; 
      $('#<%=imgCrop.ClientID%>').Jcrop (
       { // img_crop is the ID of image control 
        onChange: updatePreview, // will display the selected img on change. 
        onSelect: updatePreview, // will display the selected img Img_preview 
        onSelect: storeCoords, // will tell the coordinates 
        aspectRatio: 11/15 
       }, function() 
       { 
        jcrop_api = this; 
        var bounds = this.getBounds(); 
        boundx = bounds[0]; 
        boundy = bounds[1]; 
       } 
      ); 

     function updatePreview(c) { 
      if (parseInt(c.w) > 0) { 
       var rx = 100/c.w; 
       var ry = 100/c.h; 
       $('#<%=Img_preview.ClientID%>').css({ //Img_preview is the ID of image control 
        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' 
       }); 
      } 
     };   
    }); 

    // will store the selected part the images coordinates 
    function storeCoords(c) { 
     jQuery('#<%=W.ClientID%>').val(c.w); 
     jQuery('#<%=H.ClientID%>').val(c.h); 
     jQuery('#<%=X.ClientID%>').val(c.x); 
     jQuery('#<%=Y.ClientID%>').val(c.y); 
    }; 

</script> 

回答

0

爲IE的一個常見的解決方法是做

 $.Jcrop('#<%=imgCrop.ClientID%>', { 
       // your inits 
     });