Stop users from dragging content from the HTML Viewer

I have a site that is displayed in the html viewer, I want to prevent links and images from being dragged to the desktop / filesystem.

I have a few pieces of code that prevents right clicks etc I got from these forums, but it’s not preventing the user from dragging out the content.

under document complete event

me.ExecuteJavaScript "document.addEventListener('dragover', function(event){event.preventDefault();}, false);"
me.ExecuteJavaScript "document.addEventListener('dragenter', function(event){event.preventDefault();}, false);"
me.ExecuteJavaScript "document.addEventListener('drop', function(event){event.preventDefault();}, false);"
me.ExecuteJavaScript(context)

and context contains

document.addEventListener("contextmenu", myFunction);

function myFunction(e) {e.preventDefault(); return false;
}

Someone notes that webkit can do it with this property

-webkit-user-drag: auto | element | none;

I think that’s a webkit compile flag, I am not sure so that is not an option.

Ok I figured it out… here it is incase anyone ever needs it…

me.ExecuteJavaScript "document.addEventListener('dragstart', function(event){event.preventDefault();}, false);"

Regardare non tocare ?

What a shame :frowning:

[quote=337880:@Emile Schwarz]Regardare non tocare ?

What a shame :([/quote]

I do not understand what you meant. Are you saying it’s a shame to block users from dragging out my content from the htmlviewer? It’s displaying a private page of mine that is meant to be viewed only, not saved or copied.

print it
screen shot
you name it
if folks want it they will figure out how to get it and preserve it locally

Yeah but its a lot more work to trim out a png and it loses its alpha as well :slight_smile:

[quote=337973:@Norman Palardy]print it
screen shot
you name it
if folks want it they will figure out how to get it and preserve it locally[/quote]

Screen shots are simple and easily editable on most OSes nowadays
It doesn’t give you the text
But the determined you wont be able to stop

Its like trying to implement anti-piracy measures in a desktop app
The more you do the more people using you’re app are likely to also be inconvenienced

Preventing links to be dragged is not very bright IMHO. There are many instances in which it could be desirable to open them in a browser instead of into dumb dumb HTMLViewer. But hey, if you get your pleasure from depriving users of system features, just go ahead. Not sure that will be much appreciated, though. Reviews in online stores may be kind of stringent …

Thanks for the input, again its not for browsing the net, it’s for displaying a private page. I don’t want the page, content or the url to be publicly displayed, I get sniffers can get the information, but the common Joe won’t. You would think I shot someone’s dog by doing this…

I think what people are trying to point out… Is no matter what you do, you will not stop people from being able to share any information displayed on the screen with anyone else… so why waste the time attempting to do so?

Not at all
THAT I would get really upset at :slight_smile:

What I meant was: do not show something if you do not want it to be know.