如何禁用拖放? [英] How can I disable drag and drop?

查看:117
本文介绍了如何禁用拖放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用从HTML文件复制图片文件。我已经购买了Activ eBook Compiler禁用左键单击复制,打印和Alt + PrtScr复制到剪贴板的软件,但它仍然不会禁用拖动和放大下降。我意识到知识渊博的计算机用户可以绕过大多数禁止复制的尝试,但我想,至少要让它变得困难。我试过了:


[HTML]< BODY onBeginDrag ="返回FALSE;"> [/ HTML]


和:


[HTML]< img src =?mypic.jpg? ondrag =?return false;? /> [/ HTML]


但这两个命令在XP专业版的浏览器(IE7)中都没有任何效果。


任何人都可以提供帮助请?

I want to disable copying picture files from an HTML file. I have purchased "Activ eBook Compiler" software which disables left-click copying, printing, and Alt+PrtScr copying to clipboard but it still doesn''t disable drag & drop. I realise that a knowledgeable computer user would be able to get around most attempts to disable copying but I want to, at least, make it difficult. I have tried:

[HTML]<BODY onBeginDrag="return FALSE ;"> [/HTML]

and:

[HTML]<img src=?mypic.jpg? ondrag=?return false;? />[/HTML]

but neither command has any effect in my browser (IE7) in XP Pro.

Can anyone help please?

推荐答案

转到JavaScript论坛。


--Kevin
Moving to JavaScript Forum.

--Kevin


没有跨浏览器的ondrag事件。拖放取决于onmousemove / up / down事件。
There''s no cross-browser ondrag event. Drag/drop depends on the onmousemove/up/down events.


没有什么可以阻止你的图像被复制。

但是,是的,禁用拖动东西,在body标签中使用 onmousedown =" return false;"

但这会破坏你的输入和textareas,因为这不会让用户通过鼠标点击将焦点移动到它们上面。


因此,如果您的页面中有任何输入或文本区域,那么还有另外一种方法(有点冗长,所以只会在你需要时告诉你。


要禁用右键单击,请在body标签中使用 oncontextmenu =" return false;" 。但这与标准模式不兼容。所以用JavaScript做这件事。
There is nothing that can prevent your images from being copied.
But yeah, for disabling the drag thing, use onmousedown = "return false;" in the body tag.

But this will ruin your inputs and textareas, as this will not let the user to move focus to them with mouse click.

So if there''s any input or textarea in your page, there''s another way out (a bit lengthy, so will tell you only if you need).

For disabling right click, use oncontextmenu = "return false;" in body tag. But this is not compatible attribute with the standard modes. So rather do it with JavaScript.


这篇关于如何禁用拖放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆