Add to Google

Disabling Right Click Function

Pages: 1, 2
free web hosting
Open Discussion > CONTRIBUTE > The Internet > Web Design

Disabling Right Click Function

-Sky-
Disabling Right Click Function.

Is it possible in any way to prevent people from right-clicking on my sites pages? Also, I'd like to know if It's possible to create an HTML based Navigation bar. smile.gif
Could someone/anyone help me with this function?

I'd like to put an HTML No-Right-Click script that comes up with an error saying: "Bad move there. Right-Clicking is not allowed.".
Thanks. smile.gif

Comment/Reply (w/o sign-up)

jlhaslip
Disabling right click to prevent users from viewing Source code or protecting images is not a good idea for several reasons.

See these links:

http://www.trap17.com/forums/site-down-t60870.html
http://www.killersites.com/mvnforum/mvnfor...ead?thread=4037

Comment/Reply (w/o sign-up)

-Sky-
Oh. OK, thanks Jim. So there's no way to hide my content on my sites pages then?
I'm pretty sure copyright won't stop them either.

Second question:
Can anyone help me with a Navigation bar for my site with HTML?

Thankyou. smile.gif

Comment/Reply (w/o sign-up)

jlhaslip
QUOTE(-Sky- @ Sep 16 2008, 06:44 PM) *
Can anyone help me with a Navigation bar for my site with HTML?

Start a new Topic in the HTML Sub-forum, please.

Comment/Reply (w/o sign-up)

rvalkass
QUOTE(-Sky- @ Sep 17 2008, 01:44 AM) *
Oh. OK, thanks Jim. So there's no way to hide my content on my sites pages then?
I'm pretty sure copyright won't stop them either.


Due to the way the web works, it's impossible to totally mask the code behind a site. The browser needs to be able to read the code behind the site so that it can actually display it. If the code was hidden then the browser wouldn't be able to use it to make the page.

As for copyright - you can copyright the content of the pages (the text, images, sounds, videos, whatever) but not really the HTML code behind it.

Comment/Reply (w/o sign-up)

Nabb
You can OBFUSCATE your html code, but not HIDE it.

Firstly, you should be able to take a look at random html by simply pressing ctrl+U, or adding view-source: to the url.

If you wish to obfuscate the code, what you should be doing is encrypting the file with some form of encryption, and then have this as a variable in javascript. Then you would need to have the javascript decrypt the ciphertext and display it with document.write(stuff).
However this would pose a problem to those with javascript off...

Comment/Reply (w/o sign-up)

rvalkass
QUOTE(Nabb @ Sep 17 2008, 09:02 AM) *
If you wish to obfuscate the code, what you should be doing is encrypting the file with some form of encryption, and then have this as a variable in javascript. Then you would need to have the javascript decrypt the ciphertext and display it with document.write(stuff).
However this would pose a problem to those with javascript off...


Not only would people with JavaScript turned off see nothing, but these 'encryption' methods are futile at best. At worst, they make the load times of your pages skyrocket, and annoy users. All people need to do is view the source, and run the JavaScript locally, but this time output the result so that it can be read... Suddenly all your code appears.

Comment/Reply (w/o sign-up)

Nabb
Well it's obfuscation. You can't stop someone from getting the code because the browser needs to interpret it.

Actually can't you ctrl-a, ctrl-c, ctrl-v in a WYSIWYG editor...

Comment/Reply (w/o sign-up)

PilzzE
If you want to protect your photo's/images use a watermark on them,
You can do that in Photoshop or with a php script. PHP watermark tutorial

People hate it when you disable functionalities and pop up messages.
Altough if you use something like a .hta file then it provides some security. But on websites it is a !!NO!!.

Comment/Reply (w/o sign-up)

minimcmonkey
Ok, well mopst people will tell you to use a piece of javascript.
But this is much less useful, than a simple attribute in the <body> tag of your page.
A javascript type defence has many problems
- Someone may disable javascript to get round it
- you are not protected against people pressing the menu button on their keyboard
- you can chnage mouse buttons to right click, and most scripts only protect against button 2
- people with three button mice, often get round these scripts

you said you wanted an alert saying "bad move" or something, so i will give you code to disable the context menu, then to cause the alert, this is most effective.


To cause the context menu to not-apear when someone right clicks on your page, simply, use this in your <body> tag.
CODE
oncontextmenu="return false;"


your body tag may look like this:
CODE
<body bgcolor="112233" onmousedown="coordinates(event)" oncontextmenu="return false;">


Ok, this will not disable the "page" menu in IE 7 ect. I dont think there is a way to disable that, but it will disable the context menu.

Now for the script.

This code will cause an alert to appear, if any mouse button is clicked, other than button one.

CODE
<script type="text/javascript">
function coordinates(event)
{
if (event.button==1)
  {

}
else {
alert("bad move");
}
}
</script>

This should be placed in the head section, and run onmousedown.
However, this script will say "bad move" even on click of the middle button, fo people who want to use autoscroll, will not be le to, and will have to scroll manually, with the mouse wheel.
This code, will only say "bad move" if button two is pressed, remember, this is even easier to evade than the previous script.

CODE
<script type="text/javascript">
function coordinates(event)
{
if (event.button==)
  {
alert("bad move");
}


else {

}
}
</script>


Here is a sample of what the page could look like:

CODE
<html>
<head>
<script type="text/javascript">
function coordinates(event)
{
if (event.button==1)
  {

}
else {
alert("bad move");
}
}
</script>
<title>my Photo Gallery</title>
</head>
<body bgcolor="112233" onmousedown="coordinates(event)" oncontextmenu="return false;">
<p>Content goes here</p>
</body>
</html>


Note that none of the scripts above will cause the alert if the menu buttonis pressed, if you want that to trigger the alert, replace
CODE
oncontextmenu="return false;"

with something like
CODE
oncontextmenu="functionabc()";

Then create a javascript function with that name, that causes an alert like this:
CODE
<script type="text/javascript">
function functionabc()
{
alert("Bad move")
}
</script>


Remember that you cant ever really stop people steeling your code or imagesm, there is always a way, i wont list the ways, but im sure you can imagine.
one great way round this, is simple text.
Simply make sure, you write at the bottom of the page, what people are allowed to use your images/content for, and make sure you put author information in HTML comment tags in your code.




You said you wanted to make a navigation menu, I am happy to help you, but could you provide some more information as to what you want.
(do you want to use images, do you want something to change colour when you hover over it ect.)





 

 

 


Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Pages: 1, 2
Recent Queries:-
  1. disable right click html code - 3.19 hr back. (1)
  2. stop right click by body tag - 19.30 hr back. (1)
  3. disabling right click manually - 27.78 hr back. (2)
  4. hta disable right click - 29.07 hr back. (1)
  5. html code disable button right - 33.70 hr back. (1)
  6. html for prevent right click - 42.98 hr back. (1)
  7. not allow right click - 48.50 hr back. (1)
  8. html disable right click - 49.84 hr back. (1)
  9. disable right click html - 91.19 hr back. (1)
  10. codes to avoid right click - 92.59 hr back. (1)
  11. java script avoid right click - 92.75 hr back. (1)
  12. html prevent right click - 102.77 hr back. (1)
  13. htlm no right click - 126.74 hr back. (1)
  14. hta norightclick - 140.66 hr back. (1)
Similar Topics

Keywords : disabling, click, function

  1. Php Mail Function Not Working!
    I can't get the mail function work and I can't figure out why. (9)
  2. The Best And High Quality Templates
    The best and High Quality Templates click here (1)
    The best and High Quality Templates This one All of them are best and more than 1000 templates
    for all and support all browsers.....
  3. For Anyone Who Wants To Have Compact Image Gallery
    Click here (4)
    Mini gallery ....

    1. Looking for disabling, click, function

Searching Video's for disabling, click, function




advertisement



Disabling Right Click Function