Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox - designMode: disable image resizing handles

How can I prevent the user from being able to resize an image in designMode? (disable the handles when image is clicked)

like image 823
dEEf Avatar asked Nov 14 '08 07:11

dEEf


3 Answers

This works fine for Firefox:

document.execCommand("enableObjectResizing", false, false);

For IE i've used:

image.attachEvent("onresizestart", function(e) { e.returnValue = false; }, false);

like image 94
nmb.ten Avatar answered Sep 19 '22 06:09

nmb.ten


Say you turn contentEditable on like this:

document.body.contentEditable = true;

All you have to do is turn it off for all (or some) images.

var imgs = document.getElementsByTagName("IMG");
for (var i = 0; i < imgs.length; ++i) {
    imgs[i].contentEditable = false;
}
like image 21
nickf Avatar answered Sep 20 '22 06:09

nickf


I think you'll find this much more acceptable. Seems to work in Firefox but I'm not sure about other browsers:

document.execCommand("enableObjectResizing", false, false);

It leaves the drag and drop ability intact.

like image 44
Brendon Muir Avatar answered Sep 19 '22 06:09

Brendon Muir