PDA

Click to See Complete Forum and Search --> : protect an image


GRAHAM
Dec 24th, 2000, 04:19 PM
Hi folks,
could one of you kind people please provide me with a script that defeats someone from right-clicking an image to save it, so that I can protect some of my hard work.
Thanks in advance
Merry Christmas
GRAHAM :)

Dec 24th, 2000, 08:10 PM
<HTML>
<BODY oncontextmenu="return false">
<IMG SRC="img.gif">
</BODY>
</HTML>


but people ca always go to view->source, see where the pic is located, and download it.

GRAHAM
Dec 25th, 2000, 02:56 PM
Thanks very much Dennis,
I did have a short JavaScript written down somewhere
(can't find it)that brought up a message box stating "sorry this image is copyright" when an image was right clicked, that replaced the 'save as' dialog box.
Would you or anyone else be able to provide me with something similar in JS.

cheers
GRAHAM :)

Dec 25th, 2000, 03:40 PM
sure...


<HTML>
<HEAD>
<script LANGUAGE="JavaScript1.1">
<!--
var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false


function press(e) {
if ((ns4 && (e.which == 3 || e.which == 2)) || (ie4 && (event.button == 2 || event.button == 3))) {
alert ("Stop trying to steal my pictures...what's wrong with you anyway?")
return false
}
return true
}for (var i=0; i<document.images.length; i++) document.images[ i ].onmousedown=press
for (var i=0; i<document.links.length; i++) document.links[ i ].onmousedown=press
document.onmousedown=press
if (ns4) window.captureEvents(Event.MOUSEDOWN)
window.onmousedown=press
//-->
</script>

</head>
<BODY oncontextmenu="return false">
testing
<IMG SRC="img.gif">
</BODY>
</HTML>

GRAHAM
Dec 25th, 2000, 04:11 PM
BRILLIANT..
Thanks alot Dennis,
I,ll go and give that a whirl now.

Merry Xmas and a Happy New Year to you Dennis
and the same to all the Forum members and Admins.
especially those of you who have helped me over the past year or so,

GRAHAM ;)

Dec 26th, 2000, 11:45 AM
Will the above solution prevent someone from
saving the whole web page as Web Page?
If not, all immages would be saved in separate folder
for the thief.

GRAHAM
Dec 26th, 2000, 09:16 PM
Hi again,
Point taken Sadovod, I suppose if someone's really determined they'll find a way no matter what. At least the visitor will be informed that the image is copyright, not that it matters to some people today, as they steal complete sites from what I've seen and heard.

MasterGoon, if you can find such a script I would appreciate a copy of it.

I managed to find my original script after, it's not up to par with Dennis's script, but achieves the same end

<script language="JavaScript">
<!--
function click() {
if (event.button==2) {
alert('Copyright etc, etc')
}
}
document.onmousedown=click
// -->
</script>

Cheers all
GRAHAM :)