Firefox - designMode:禁用图像调整大小手柄
如何防止用户在设计模式中调整图像大小? (单击图像时禁用手柄)
How can I prevent the user from being able to resize an image in designMode? (disable the handles when image is clicked)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这对于 Firefox 来说效果很好:
document.execCommand("enableObjectResizing", false, false);
对于我使用过的 IE:
image.attachEvent("onresizestart", function(e) { e .returnValue = false }, false);
This works fine for Firefox:
document.execCommand("enableObjectResizing", false, false);
For IE i've used:
image.attachEvent("onresizestart", function(e) { e.returnValue = false; }, false);
假设您像这样打开 contentEditable:
您所要做的就是为所有(或部分)图像关闭它。
Say you turn contentEditable on like this:
All you have to do is turn it off for all (or some) images.
我想你会发现这更容易接受。 似乎可以在 Firefox 中使用,但我不确定其他浏览器是否也可以:
它保留了拖放功能。
I think you'll find this much more acceptable. Seems to work in Firefox but I'm not sure about other browsers:
It leaves the drag and drop ability intact.
好吧,你无法在 Firefox 和 IE 中删除这些调整大小处理程序......至少我找不到解决方案。
最后,我通过编辑 FF 安装文件夹中的一些配置文件在 Firefox 中进行了管理,但我们不想这样做,对吧?
无论如何,如果你想禁用图像大小调整(但调整大小处理程序仍然可见),只需添加一些 css 样式,例如:
问候,
米哈伊洛
Well, you cannot remove those resize handlers neither in Firefox nor IE... at least I couldn't find a solution.
At the end I managed that in Firefox by editing some configuration files from FF installation folder and we don't want to do that, right?
Anyway, if you want to disable resizing if images (but resize handlers will still be visible) just add some css style like:
regards,
Mihailo
虽然这个问题已经很久了。
每个块元素(div、img...)都将用 FF 的句柄进行装饰。
测试一下:
没有手柄,没有调整大小等。
图像可以调整大小。
因此,您必须为您不想拥有句柄的每个块元素显式调用 contenteditable="false",正如 nickf 已经针对图像所说的那样。
更奇怪的是:
将“position:absolute”分配给任何元素 - 甚至是父 div - 并且它再次具有句柄。
Although the question was a long time ago.
Every block element (div, img...) will be decorated with handles from FF.
Test it:
No handles, no resize etc.
The image can be resized.
So you have to explicitly call contenteditable="false" for every block elem you do not want to have handles, as nickf said already for the images.
Even more weird:
assign "position:absolute" to any of your elements - even the parent div - and it has handles again.
我还不能发表评论和投票,所以...根据 nmb.ten 的回答,你必须使用:
但是它仅在你的内容填写完毕后才有效(我的意思是如果您必须编辑之前保存的一些文本)。
I cannot comment and vote yet so... according to nmb.ten's answer, you have to use:
But it works only after your content is filled in (I mean if you have to edit some text saved before).