 |
 |
Disabling right click?
|
 |
|
 |
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
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
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status:
Offline
|
|
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
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
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
|
|
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
|
|
Secret code? Now this I've got to see.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
|
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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]
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|