Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Disabling right click?

Disabling right click?
Thread Tools
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Mar 23, 2005, 07:49 PM
 
i hate how long the script is :( and searching for a way to disable rightclick but use the least about of lines

Code:
<script language=JavaScript> <!-- //Disable right mouse click Script //By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive //For full source code, visit http://www.dynamicdrive.com var message="Yo! This is my site and my files \n Please ask the webmaster \n if you can have it"; /////////////////////////////////// function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") // --> </script>

could i make it in the head of my html and php files do
Code:
<script scr=disable.js></script>
and then have a js file with all the code to disable right click in it?
     
Mac Elite
Join Date: Mar 2001
Location: Madison, WI
Status: Offline
Reply With Quote
Mar 23, 2005, 09:09 PM
 
Why?
I do not like those green links and spam.
I do not like them, Sam I am.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Mar 23, 2005, 10:47 PM
 
Originally posted by jay3ld:
could i make it in the head of my html and php files do
Code:
<script scr=disable.js></script>
and then have a js file with all the code to disable right click in it?
You try it and tell me whether or not you can do that. It's not as though sticking a line at the top of an HTML file is such an laborious process that it requires research beforehand.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status: Offline
Reply With Quote
Mar 24, 2005, 03:15 AM
 
i don't see the point in this.

if it's to protect images and stop people right-clicking to save, i can just view source, see the image paths, and then load'em up if i want to save them. if you wanted to be really arsey about it, you could use Flash in the way that Flickr does; except that they offer a link to the actual image, too. either way, there's nothing to stop someone screengrabbing the image . or running wget on the site and taking everything on your site.

if it's to view source, there's a menu option on every browser.

the point being: it's just extra work for the sake of it, and it makes you look a bit precious (in my opinion).

what's your particular reason for wanting to do this?
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Mar 24, 2005, 04:26 AM
 
document.oncontextmenu = function(){return false;};

or the new Function way in your script. That'll work for most browsers you'll get coming to your site (well, I presume it'll work in IE, but I'm not going waste my time actually testing something like this )

But, as everyone else has said, why do you want to do this? It's incredibly simple to get round and just pisses the hell out of people who want to use the context menu for something else.

And anyway, there's nothing really wrong with the script you posted being that many lines - it's just browser checking for the people who haven't upgraded in the last 7+ years...

Oh yeah, and of course you can put that in an external JS file and just link it. It's good practice to do that for all scripts you're going to use teh web.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status: Offline
Reply With Quote
Mar 24, 2005, 04:53 AM
 
Originally posted by Black Book:
I'm not going waste my time actually testing something
right there, that's your motto
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Mar 24, 2005, 06:39 AM
 
Originally posted by Phil Sherry:
right there, that's your motto
Shap u!

For that comment, I'll buy the first round and you can buy the rest
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Junior Member
Join Date: May 2001
Location: Madison, WI USA
Status: Offline
Reply With Quote
Apr 16, 2005, 08:58 AM
 
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Apr 16, 2005, 10:21 AM
 
I've been screwing with this idea as a mental exercise. I saw someone create a script to do this on another forum, and I was thinking I could do it more thoroughly. The biggest problem I face with it is that I think the notion of restricting usability and disabling expected features on your site (That would be adding counter-intuitivity for lack of a better term) is a terrible one, but in learning javascript I thought it would be a fun project to tackle. So the big hump to get over is that this sort of script goes against everything that I believe in, but that does add an element of amusement at the same time.

I've managed to make a dreadful page from it, however. It's delightfully frustrating to use. It still needs some more work though. I'm convinced that with a little time and effort I can make the page even more difficult to use. I'm currently wanting to add another layer of un-usability to it, I figure that if I set the img src in the mark-up to blank (<img src="" alt="picture of whatever" />, I can parse the class attribute or the alt attribute or both to dynamically create the url of the image, and load it in. That would require the user to not only have to view source, but also poke around the script to find all of the pieces of the url. What's more is that I could set an attribute to a tag like the body tag, and use that as the path name to images that I wouldn't the user to steal.

I feel so dirty. But it's fun. But even still, it's hardly foolproof. The status bar in most browsers gives it all away, and the Activity Window in Safari provides one-click access to the image.

But it is a fun exercise, none the less. I
     
jay3ld  (op)
Senior User
Join Date: Jul 2004
Status: Offline
Reply With Quote
Apr 17, 2005, 12:55 AM
 
i do it 2 protect allot of my secret code. i do allot 2 protect it and doing this is just 1 more way to : censor: them off
     
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status: Offline
Reply With Quote
Apr 17, 2005, 07:35 AM
 
Originally Posted by jay3ld
i do it 2 protect allot of my secret code. i do allot 2 protect it and doing this is just 1 more way to : censor: them off
Still a waste of time.
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Apr 17, 2005, 08:58 AM
 
Secret code? Now this I've got to see.
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Apr 17, 2005, 02:04 PM
 
It's ROT-13, isn't it?
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Apr 17, 2005, 03:45 PM
 
Do you have a link we could see?
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Apr 20, 2005, 02:50 AM
 
Originally Posted by Chuckit
It's ROT-13, isn't it?
EBG-13 vf gru orfgrfg rapelcgvba, rine!!

Takes me back, does that
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Moderator
Join Date: Mar 2004
Location: Copenhagen
Status: Offline
Reply With Quote
Apr 20, 2005, 05:21 AM
 
Originally Posted by Black Book
EBG-13 vf gru orfgrfg rapelcgvba, rine!!
Do you want some help removing that gag?
     
Mac Enthusiast
Join Date: Jan 2002
Status: Offline
Reply With Quote
Apr 21, 2005, 12:57 AM
 
I think it'd be quite fun to have a dynamic .js file that document.writes your entire pag. For instance,

index.php
--------
Code:
<script language="javascript" src="annoyingPageCreator.js?page=#PAGEID#"></script>
annoyingPageCreator.js
--------
[PHP]

var line;

<?php

/*
Not exactly sure if this is what we'd want, but who really cares?
*/
if($_SERVER['HTTP_REFERER'] == "index.php") {

$pageSource = getSource($page);

$pageSource = addslashes($pageSource);

print("line = '" . $pageSource . "';");

}

?>
document.write(line);
[/PHP]
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:22 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2