我很难调试它,因为它没有返回任何错误,而且它在ie9中运行。我想知道是否有某种常见的问题导致脚本在ie9中运行,而不是在ie8和ie10中。我觉得这个bug跳过一个版本是相当奇怪的。
我的代码:
<script type="text/javascript">
jQuery(function($){
// Create variables (in this scope) to hold the API and image size
var jcrop_api,
boundx,
boundy,
// Grab some information about the preview pane
$preview = $('#preview-pane'),
$pcnt = $('#preview-pane .preview-container'),
$pimg = $('#preview-pane .preview-container img'),
xsize = $pcnt.width(),
ysize = $pcnt.height();
console.log('init',[xsize,ysize]);
$('#picture').Jcrop({
aspectRatio: <?php echo $_POST["aspectRatio"]; ?>,
setSelect: [ 0, 0, 300, 300 ],
onSelect: updateCoords
},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;
// Move the preview into the jcrop container for css positioning
$preview.appendTo(jcrop_api.ui.holder);
});
function updatePreview(c)
{
if (parseInt(c.w) > 0)
{
var rx = xsize / c.w;
var ry = ysize / c.h;
$pimg.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'
});
}
};
function updateCoords(c)
{
$('#x').val(c.x / <?php echo $correctieCoordinates; ?>);
$('#y').val(c.y / <?php echo $correctieCoordinates; ?>);
$('#w').val(c.w / <?php echo $correctieCoordinates; ?>);
$('#h').val(c.h / <?php echo $correctieCoordinates; ?>);
};
function checkCoords()
{
if (parseInt($('#w').val())) return true;
alert('Please select a crop region then press submit.');
return false;
};
});
</script>在ie8和ie10中没有初始化jcrop函数。但在ie9和所有主流浏览器中都能工作。
发布于 2013-10-11 09:15:22
改变
$('#picture').Jcrop({至
jcrop_obj = jQuery.Jcrop('#picture', {成功了。
https://stackoverflow.com/questions/19314185
复制相似问题