Try the following:
function crop(img_id, crop_id, x, y, width, height) { $(crop_id).update('<img id="' + crop_id + '_img" src="' + $(img_id).getAttribute('src') + '" style="display:none" />'); var scale_x = $(crop_id).getWidth() / width; var scale_y = $(crop_id).getHeight() / height; $(crop_id).setStyle({ position: 'relative', overflow: 'hidden' }); $(crop_id + '_img').setStyle({ position: 'absolute', display: 'block', left: (-x * scale_x) + 'px', top: (-y * scale_y) + 'px', width: ($(img_id).getWidth() * scale_x) + 'px', height: ($(img_id).getHeight() * scale_y) + 'px' }); }
Problem: JQuery is required, and the solution probably works in IE8 + .... do you need it for IE6 +?
source share