Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-18-2001, 01:10 AM   #1
Marci Sarwan
LQ Newbie
Registered: Jan 2001
Location: Canada, Toronto
Posts: 17

Rep: Reputation: 0


does anyone know how to create a java script that will prevent people from righ-clicking on an image on my web site to copy the pic? Basically, I don't want people to copy the image on my web site by right-clicking on the image and saving the image. What I want to happen when the user right click on the image is to pop up a window and prompt the user that they're not allow to copy the image. Thank you!

Marci Sarwan (

PS: Please include some sample code. Thanks!
Old 01-18-2001, 09:18 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,147

Rep: Reputation: 229Reputation: 229Reputation: 229

You can use the code off of one of my websites, but I haven't updated it but it doesn't work in Linux, or the new version of Netscape 6.0. But you can at least see waht it looks like and customize it to your tastes.


Here it is: goes after Title tags--


var message="Any message you want goes here";

function click(e) {
if (document.all) {
if (event.button == 2) {
return false;
if (document.layers) {
if (e.which == 3) {
return false;
if (document.layers) {
// End -->


Hope this helps in any way. But remember unless you make it pop up in a different window with the option to use the menu 's up at the top of the browser windows, anyone can go t view and see the source...then they can see where you have the pic stored.


Sorry forgot to add this....

<body OnLoad="trap()\" BGCOLOR="#000000"> the onload functions needs to be in your body tag...

[Edited by trickykid on 01-18-2001 at 10:21 AM]


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript help darin3200 General 4 09-03-2005 11:58 PM
Javascript maseby Programming 1 04-09-2004 05:16 PM
javascript in <td>? akaash Programming 0 03-18-2004 12:22 AM
JavaScript TextAreas jacksmash Programming 9 12-27-2003 01:02 PM
Help with javascript? BajaNick Linux - Software 2 07-20-2003 08:41 PM

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration