473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How can I disable drag and drop?

3
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?
Jun 30 '08 #1
18 36648
eWish
971 Expert 512MB
Moving to JavaScript Forum.

--Kevin
Jul 2 '08 #2
acoder
16,027 Expert Mod 8TB
There's no cross-browser ondrag event. Drag/drop depends on the onmousemove/up/down events.
Jul 2 '08 #3
hsriat
1,654 Expert 1GB
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.
Jul 3 '08 #4
Maybe you can find some help here: DELETED
Jul 8 '08 #5
acoder
16,027 Expert Mod 8TB
What does that have to do with the original question?
Jul 8 '08 #6
RamananKalirajan
608 512MB
Respected Sir,
I am not sure that whether I am giving the correct answer but somehow this will help you to prevent your picture copied.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.   <script langauge="javascript">
  4.   function onDrag()
  5.   {
  6.     alert("selected");     
  7.   }
  8.   </script>
  9. </head>
  10. <body>
  11. <div id="myDic" onmousedown="onDrag()">
  12. <br/>
  13.  <img src="1.jpg" >
  14. <br/>
  15. </div>
  16. <br/>
  17. </body>
  18. </html>
Just try this one.

Regards
Ramanan Kalirajan
Jul 8 '08 #7
hsriat
1,654 Expert 1GB
Isn't onmousedown = "return false;" a better option?
Jul 8 '08 #8
acoder
16,027 Expert Mod 8TB
To protect images, watermark them. As soon as you display them on your page and someone visits it, it's been downloaded, so any script won't protect an image.
Jul 8 '08 #9
Plater
7,872 Expert 4TB
When I was in college, an assoicate of mine was working on something sneaky.
He had an html page (on his server) with images. And a challenge to try and get a copy of them without using the printscreen(screen capture) button.
If you higlighted the image, it changed.
If you right-clicked and said save image, it was a different image.
if you went to the URL of the image, it was a different image.

I don't know how he did it, but he was sneaky like that.
Jul 8 '08 #10
hsriat
1,654 Expert 1GB
To protect images, watermark them. As soon as you display them on your page and someone visits it, it's been downloaded, so any script won't protect an image.
Moreover there's a "Prt Scr" key.
Jul 8 '08 #11
acoder
16,027 Expert Mod 8TB
Moreover there's a "Prt Scr" key.
True, though the OP said this key was disabled. One simple way to protect the content would be to create a transparent div over the content. No matter where the user clicks, they can't get at the content. The only way they can get the image is by viewing the source and finding the image source, or modifying the source to remove the div.
Jul 9 '08 #12
acoder
16,027 Expert Mod 8TB
When I was in college, an assoicate of mine was working on something sneaky.
He had an html page (on his server) with images. And a challenge to try and get a copy of them without using the printscreen(screen capture) button.
If you higlighted the image, it changed.
If you right-clicked and said save image, it was a different image.
if you went to the URL of the image, it was a different image.

I don't know how he did it, but he was sneaky like that.
Could you not check the source or disable scripting?
Jul 9 '08 #13
mclerp
3
Respected Sir,
I am not sure that whether I am giving the correct answer but somehow this will help you to prevent your picture copied.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.   <script langauge="javascript">
  4.   function onDrag()
  5.   {
  6.     alert("selected");     
  7.   }
  8.   </script>
  9. </head>
  10. <body>
  11. <div id="myDic" onmousedown="onDrag()">
  12. <br/>
  13.  <img src="1.jpg" >
  14. <br/>
  15. </div>
  16. <br/>
  17. </body>
  18. </html>
Just try this one.

Regards
Ramanan Kalirajan


Thank you for the solution to my problem. This routine, combined with the eBook Compiler software, disables all copying after the files are compiled. Your help is very much appreciated ..... mclerp
Jul 13 '08 #14
mclerp
3
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.


Thank you for your help. I haven't been able to get this to work but that's probably because I don't know how to write the full code. As a Newbie, I am VERY new and haven't written any Java script before. However, the routine described by RamananKalirajan works well. Thanks to everyone who has replied to my question ..... mclerp
Jul 13 '08 #15
acoder
16,027 Expert Mod 8TB
Just a couple of notes:
1. The script language attribute is deprecated, so use type instead:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
2. Unless you want to display a message, return false as hsriat pointed out is better:
Expand|Select|Wrap|Line Numbers
  1. <div id="myDiv" onmousedown="return false;">
Jul 14 '08 #16
solnyc
2
Thank you for your help. I haven't been able to get this to work but that's probably because I don't know how to write the full code. As a Newbie, I am VERY new and haven't written any Java script before. However, the routine described by RamananKalirajan works well. Thanks to everyone who has replied to my question ..... mclerp
Hi RamananKalirajan,

I tried using that code you wrote for the "image disable". You'd had said there is a way to get around the text issue so folks can type in input boxes while not being able to drag images.

Can you explain how to do this?

Thanks in advance
Oct 23 '08 #17
rnd me
427 Expert 256MB
two tricks that work even if javascript is disabled:

1. change the images to relative positioned divs, height and width specified. then set the background-image to the .src of the img tag the div replaces.

2. place a relative positioned, background-color: transparent, height and width specified, border: 0px text input in front of the image. this clear input intercepts clicks even without javascript, giving you the crappy input-related menu options like paste, select All, and copy.
Oct 23 '08 #18
solnyc
2
It seems that there is no multi-browser script that keeps users from downloading/dragging images to their computer desktop.

or is there?
Oct 23 '08 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
4
by: zav | last post by:
Hi all i`m having a small problem with windows forms, i`m attempting to provide the following functionality to a form. Ability to drag and drop another form onto a form and then to dock this...
4
by: Qingdong Z. | last post by:
I have a VS.NET windows application which use drag-drop feather. It works fine when application start, but stops working after application run one or two days. The application is related to Video...
0
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the...
1
by: timnels | last post by:
I have created a muti-select treeview control. Problem is I am now trying to implement drag/drop in the application that uses it. It seems the mouse down and mouse move events fire before the...
9
by: surf_doggie | last post by:
Im not sure if this is the group to post in, if anyone knows a more appropriate one please let me know. Please consider the following example of a feature most all browsers have that I would...
1
by: gilan | last post by:
I'm building a javascript WYSIWYG editor using designMode. My main problem right now is that I'm trying to create dragging functions for certain classes of divs, but Firefox's own designMode...
4
by: Jeff | last post by:
Hello, I am trying to drag and drop a label control from one cell in a tablelayoutpanel to another (VB2005). There is no problem if both cells are visible, but i cannot get the tablelayoutpanel...
2
by: bob | last post by:
Hi all, I have a treeview that has drag drop. Works well enough but... If you drag out of bounds of the treeview the nodrop icon comes on. Fair enough. But when I move back inside the treeview...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.