#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    488
    Rep Power
    46

    Message on Right Click


    I am reworking an old website and have a bit of JS that I put in years ago to prevent right click and show an alert message. Now I am sort of doing some "Touch Up" and this script doesn't work anymore. It probably needs some updated code and I am just not familiar enough with JS to figure it out effectively.

    I hope someone can modify it, if simple enough, to make it work. I sure appreciate the help.
    Code:
    	<script language="JavaScript">
    	<!--
    	var message="WARNING ! All content contained within this site is protected by copyright laws.\n                    Unauthorized use of our material is strictly prohibited.";
    	function click(e) {
    		if (document.all) {
    			if (event.button==2||event.button==3) {
    				alert(message);
    				return false;
    			}
    		}
    		if (document.layers) {
    			if (e.which == 3) {
    				alert(message);
    				return false;
    			}
    		}
    	}
    	if (document.layers) {
    		document.captureEvents(Event.MOUSEDOWN);
    	}
    	document.onmousedown=click;
    	// -->
    </script>
    Thank You.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Saint-Petersburg, Russia
    Posts
    240
    Rep Power
    29
    Though this problem could be solved as it is done in most of google products - but are you sure you need this?

    To be honest, I suspect that many web-users really hate when site overrides the behavior of the right click, especially when it is not really necessary (like in case with some complex google sites).
    CodeAbbey - programming problems for novice coders
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    488
    Rep Power
    46
    Thanks. Yea, I need it, we have a very limited user-base and we have found our images on competitions websites.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    26
    Rep Power
    0
    Originally Posted by additude
    Thanks. Yea, I need it, we have a very limited user-base and we have found our images on competitions websites.
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>contextmenu</title>
    </head>
    <body>
    <img src="whatever.prg"
    oncontextmenu="alert('No,No');return false">
    </body>
    </html>
    This will not deter image
    theft. It's purpose is to
    provide an alternative
    menu.

    google contextmenu
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    77
    you do realize people can do Crtl + U to get all of the source code and can just copy the image url from there?

    also there is developer tools, F12 on most browsers and firebug on Firefox

    plus all you would have to do is disable javascript and you can copy the images

    this method doesn't work, has never worked, and will never work and only angers any people viewing the website
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    488
    Rep Power
    46
    Yep, I realize all of that and this is not to stop image copying. I think I can even use CSS to position a transparent gif over the top of the images.

    I am aware of all the bad and this is just a reminder for those who want to harvest.

IMN logo majestic logo threadwatch logo seochat tools logo