Javascript: Disable Mouse Right-click In Browser

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #16) by TavoxPeru on Mar 8 2008, 06:43 AM. (Line Breaks Removed)
Another way for disabling the mouse right-click is by using the oncontextmenu event, if you add this javascript code:CODE<body oncontextmenu="return false">to the body tag, you disable the context menu that appears whenever you right click in your page.For protect your images you can use another image that covers the one you want to protect or a div that covers all your page (locat... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Free Web Hosting > Computers & Tech > Programming > Scripting > JavaScript

Javascript: Disable Mouse Right-click In Browser

wannabeeaweak
just copy and paste this on to your html site in the head tag

CODE

<script language="JavaScript">
<!--
/*
*/

var message="Hey YOU!\nStop Stealing my pictures or\nFACE THE PUNISHMENT!"



function click(e) {
if (document.all) {
if (event.button == 2) {
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>

Reply

k22
But if you want to use it anyway just use firefox(no the 1PR version) and add this plugin biggrin.gif
https://update.mozilla.org/extensions/morei...p?id=89&vid=101

Reply

overture
or just add this to your body tag:
CODE
oncontextmenu="return false"

that will stop right-click in IE. It won't return a message but it does stop this. I have given this out before in another topic along with a couple more pieces for all those who still want to use it(i see no reason to). I have also stated that it will not work in Firefox(any version), it only works in IE.

Reply

qwijibow
this doesnt work in most browsers.. and even if it did, it doesnt stop people from clicking "View source" and EEEVEN if it did that, then it wouldnt stop people getting the source with telnet.

this code is useless, sorry, and its been poted many times already by other people.

Reply

UberVamp44
For HTMl i was told that this would work also }no right click{ well some thing like that

Reply

dcy
i dont know if it is important to stop your right-click in IE, as for me i dont use it,
everytime when i want to copy or paste somethings , use right-click is very good,
but use right-click it will block somethings,just like when someone want to view your site's source code, so i dont use right-click!

Reply

wannabeeaweak
yes all this stuff is true but this script help for people to not get your source code cause u don't want people to have the same stuff on there site as u do

Reply

overture
but it will not stop people (most of them anyway) there are ways around it like using a different browser, or you could just save the page and view the html from the saved pages (right-click the document and click open with Notepad, or something like that). Sorry to say that.

Reply

bx93
This is important for someone to keep safe their product which they use to get money. See the following link: http://www.entheosweb.com/website_template...ew/learning.asp

However, I don't know how to achieve this, as I could not open the link in a new window, and don't know how to save the html.

Reply

bbdesign
sure.... that works, unless the person disables javascript

Reply

Latest Entries

TavoxPeru
Another way for disabling the mouse right-click is by using the oncontextmenu event, if you add this javascript code:
CODE
<body oncontextmenu="return false">

to the body tag, you disable the context menu that appears whenever you right click in your page.

For protect your images you can use another image that covers the one you want to protect or a div that covers all your page (located in front of your page) like:
CODE
<div style="width:100%;margin:0px auto;z-index:10;top:0px;left:0px;background-color:transparent;height:100%"><img alt="image alt text" src="imagename" ></div>

And of course, you can use the imagetoolbar meta tag, this one will not protect your images, it simply disallow the image toolbar of Internet Explorer and Firefox:
CODE
<meta http-equiv="imagetoolbar" content="no">

Best regards,

Reply

KDEWolf
QUOTE(jc804 @ Mar 7 2008, 06:29 PM) *
Don't forget about the PrintScreen button on your keyboard.
Disabling right-click could be useful, but it won't protect your images.
Put in a water-mark and maybe decrease the resolution to a preview edition to protect your images.

Yes that's the way to go to protect images. But nowadays you've got to put the watermark in the very middle of the picture, since it's very common to have people cropping the original picture to remove watermarks from the borders and alike.
A clear example of it is the watermark option in DeviantArt. It's huge, it's very noticeable and right in the image center. It's actually awful to look at that, since it kind of screws the picture mood, but in the case of having constant problems, it's the only way to go.

Reply

jc804
Don't forget about the PrintScreen button on your keyboard.
Disabling right-click could be useful, but it won't protect your images.
Put in a water-mark and maybe decrease the resolution to a preview edition to protect your images.

Reply

KDEWolf
This is not only an annoying measure, it also cripples deeply usability. Not to say that nowadays with the steady growth of alternate browsers, mostly Firefox, Safari and Opera, it simply won't work. It's VERY hard to "hide" things like HTML/CSS/JS code from a curious or bad intentioned reasonably intelligent person.
I'd say this one is a big no-no.

Reply

TavoxPeru
QUOTE(FeedBacker @ Feb 18 2008, 12:38 AM) *
How to desable right click while opening new window?

java script: Disable Mouse Right-click In Browser
Hi,
I know how to desable right click in winow but I am unable to desable right click in new window.When ido I click on link and open a new window.
Pls reply..
Please do the needful.
-Amit Tiwari

I don't understand completely but in case the new window is yours then you must copy the code to it also, by yours i mean that you are the owner -the one who makes the page- of the opener and of the new window.

And, i don't know if it works with Safari because i don't use it.

Best regards,

Reply


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*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. php script disable second mouse - 6.65 hr back. (2)
  2. right mouse menu javascript - 8.24 hr back. (1)
  3. javascript unable right click - 19.34 hr back. (1)
  4. desable javascript.com - 32.43 hr back. (1)
  5. disabling browser close button using java - 37.23 hr back. (1)
  6. disable right mouse click javascript - 38.73 hr back. (1)
  7. javascript disable mouse click on web - 38.82 hr back. (1)
  8. disable right click option in javascript sample code - 38.99 hr back. (1)
  9. javascript block righte mouse option - 49.52 hr back. (1)
  10. javascript block right mouse option - 49.69 hr back. (1)
  11. javascript disable right button - 55.70 hr back. (1)
  12. disable copy option all browsers - 56.40 hr back. (2)
  13. javascript how to disable mouse right click paste - 58.52 hr back. (1)
  14. javascript disable right click menu - 59.22 hr back. (1)
Similar Topics

Keywords : javascript, disable, mouse, click, browser

  1. Javascript Changes Aren't Working.
    (6)
  2. Javascript Help Needed : Alert(z) Works Fine But Document.write Not
    please (2)
    hi all, I am facing problem in my javascript, any kind of help would be apreciated CODE
    function basicFiles(){ //var Z = "";             for (i = 0; i <
    document.Form.regionlist.options.length; i++) {                 var x =
    document.Form.regionlist.options[i].value;                 var y =
    document.Form.regionlist.options[i].text;                 var Z =  "regions" +
    "[" + x + "]" + " = " + y + ", ";
                    alert(Z);             }                   } th....
  3. When A User Close The Browser Window
    How to control this action (1)
    I know that when a user leaves your website you can perform any action if you add some code to the
    onunload event like for example display an alert box, pop-up a window, etc. but when the user close
    the browser window instead which event is fired up??? how to control this action??? is it possible
    to add some code to perform when this happens???? Best regards,....
  4. Fun With Javascript And Forms
    Lets have some fun with javascript! (2)
    I will post here every week with new and exciting things to do in javascript! After i finish 10
    of them , ill do Ajax(real-time) - 1.Alerting and documenting Forms Ever seen those dynamic sites
    where if you hove your mouse or type something bad..etc , it popups up or dynamically gets written
    onto the page? Well i am here to teach or rather help with all that stuff! Step 1:Get notepad
    out and make a form CODE <form name='test'> <input type='text'
    name='field1'> Text displays here: <div id='r'> &....
  5. Include Function For Javascript
    (7)
    I've been working on an include function for javascript. It works just fine in Firefox and IE,
    but for some reason, it doesn't result in the loading of the scripts for Safari. The code is as
    follows: CODE function include(url) {   // Include Guard   var scripts =
    document.getElementsByTagName("script");   for (var index = 0; index <
    scripts.length; ++index) {     if (scripts.src == url) {       return;     }   }      //
    Inclusion   var head = document.getElementsByTagName("head").item(0);   ....
  6. Problem With Javascript Alert();
    (9)
    Hi Everyone, i just need to know that this javascript code is formatted correctly: (A piece of
    code that it's written BESIDE an HTML code.) CODE <body onLoad="alert('My
    Text Here');">My body contents</body> |||Always keeps telling me that
    this was incorrect. ....
  7. Get Mouse Position
    (4)
    Hi, Does anyone know a way to get the mouse co-ordinates from JavaScript? Im making a thing where
    you drag and drop objects on a page, and I know how to do it, except for this bit, so if anyone
    knows, that's help. Thanks!....
  8. Javascript: How Do I Create Embedded Pop-up Windows?
    (7)
    The post title summarises my query - how do I create pop-up windows that are embedded inside a page?
    Broadly, there are two kinds of JavaScript pop-ups.. one is that ultra annoying one, which pops
    out a new instance of a browser window and displays something there (usually an ad) - made infamous
    by all the warez and porn sites. Second one, which has come to be quite well-known of late is the
    kind you see in recent versions of WordPress (in the Visual Editor) as well as LightBox based
    galleries. Here a small window (or rather a div) pops-up embedded in the middle of t....
  9. Javascript Question
    Vertical Scroll Box (4)
    Alright well I've been working and modifying this template for about a year now I think and
    I've started used JavaScript in it (bad to use templates I know, but I can't design them
    x_x). So I'm trying to put a vertical scroll box in my side events panel to save space, but it
    won't recognize the script. It takes the horizontal one I have as you can see if you look at
    the site, but not the vertical. Actually it won't take anything in that little panel. So my
    question really is, what could cause a javascript code to not work on a certain webpage ....
  10. Add Text To Textarea
    I suppose it uses DOM and JavaScript?? (6)
    I am working on a web "application" thing that allows you to click a button to add text to a
    textarea. Similar to this forum when you click the BOLD button and it puts in {b}{/b} with the
    square brackets. I want a similar function like that. Also, I want it to add wherever the cursor is,
    not at the end. And after adding the thing, the cursor should be in between the tag or whatever that
    was added. All the extra stuff are extra priorities. For now I would like to get something that
    inserts text on click. The thing I came up with is: HTML html > head > <script ....
  11. One Click To Copy Script
    Works in IE6 but not any other Browsers (0)
    As a project to "boilerplate" some text, I had this idea of making a couple of textareas in html and
    having a single click on the input button copy the contents to the clipboard and then pasting the
    text into another blank textarea. Several textareas would contain the different pieces of text and I
    would then be able to 'assemble' the full text into the 'blank' textarea and then,
    of course, copy this entire piece to the clipboard and migrate it to the final spot for copying.
    Anyways, BuffaloHELP had the basic code for the javascript, but it seems that thi....
  12. Problems With Dynamically Loading Javascript
    As well as dynamically inserting HTML (2)
    Hello, I have started to try to create a JavaScript application (or rather, AJAX, but the
    JavaScript is the part I'm having trouble with). I have come across a roadblock, though. I try
    to load an external JavaScript file by editing the innerHTML of a div tag to contain <script
    src="URL" type="text/javascript"> (with a real URL). The problem is that it is not loading. I have
    used FireBug to check the dynamic HTML status, I get the following (with code removed): CODE
    <html> <head/> <body> <div id="status"/> <div id=....
  13. I Need Help With Javascript.
    help plz (7)
    Well, I want to learn to code in JavaScript, but when I try to view the page in Firefox, it
    dosen't work. Can anyone tell me why its not working? Do i need to use a different browser?....
  14. JavaScript Off Redirect Script
    How to redirect a browser when Javascrip (2)
    Hi, here's a trick that will redirect a browser when JavaScript is turned off. Why not redirect
    the ones that have JavaScript? It's because less than 10% of browsers have JavaScript turned
    off; therefore, is better to redirect less than 10% of visitors than over 90%. Simply paste this
    code into the HEAD section of your HTML document. CODE <script
    type="text/javascript"> <!-- /* Created by: Will Bontrager ::
    http://www.willmaster.com/ */ <noscript> <meta http-equiv="refresh"
    content="0; URL=ht....
  15. JavaScript Frames & Querystring
    (4)
    Hi, I actually want to create a HTML page which has the capablity of reading a QueryString
    (x.html?querystring=test) and then using a hidden frame pass on the data to an ASP Script on another
    server. For obtaining the QueryString i use the following:- CODE <script> function
    getQueryVariable(variable) {   var query = window.location.search.substring(1);
      var vars = query.split("&");   for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");     if (pair[0] == variabl....
  16. Vertical Marquee Using JavaScript
    by The JavaScript Source (0)
    Hi, i find this script and hope that will be useful for somebody. Text scrolls from bottom to top,
    pauses, then scrolls up and out of view. A link can be added, opening in a new window. Configuration
    is simple. First copy the following code in a new file and name it vertical.js CODE /* This
    script and many more are available free online at The JavaScript Source ::
    http://javascript.internet.com Created by: Mike Hudson ::
    http://www.afrozeus.com */ /* To change the values in the setupLinks function below. You will
    notice there are two arr....
  17. Create And Import JavaScript Modules For A Large Script
    (2)
    I have one main script which defines an object. I then have several other script files that define
    functions for that object. I have tried using the following setup to import the functions: HTML
    code snippet: <script type="text/javascript" src="/foo/mainbar.js"> <script
    type="text/javascript" src="/foo/modulebar.js"> Javascript code snippet: import
    Object.functionName; This works fine for Mozilla Firefox, but causes an error in Internet Explorer
    which causes the object to be undefined. I would like to know how better to import the functions
    into the m....
  18. Ever Needs To Find Out A Table Height Or With With JavaScript
    Well stop looking, here is the answer (CSS and JS) (2)
    Welcome everybody to this litle tutorial. by v.DragonEyE.n09 Introduction: Using
    javascript you can find the height and width of a table, cell, div, image, etc.. the more simple way
    is to ask for this... QUOTE id= "myElement" border= "0" cellpadding=
    "0" cellspacing= "0" style= " height : 300px ; width
    : 450px ; " > some
    fake text and images for the example some fak....
  19. JavaScript: Hide And Show Any Element With CSS
    From the simple way to the more advanced way (Javascript & CSS) (5)
    Welcome everyone, this is my first post. The first thing you need to know is... CSS
    has two special attributes, the first one is " display " and the second is " visibility ". The
    difference between these two goes like this. " display ": has many properties or values, but the
    ones we need are "none" and "block". "none" is like a hide value, and "block" is like show. If you
    use the "none" value you will totally hide what ever html tag you have applied this css style. If
    you use "block" you will see the html tag and it's content. very simple. " visibi....
  20. JavaScript: Simple Dropdown Menu
    Simple Dropdown Menu (1)
    This simple dropdown menu is flexible enough to be used in various ways. It can be placed and
    modified in the webpage as is.....
  21. Javascript: Simple Slidedown Menu
    Simple Slidedown Menu (2)
    This is a simple slidedown from the top menu. It can be placed on the Webpage as is. To modify it
    to a slideout menu, simply change the style and postion of the menu.....
  22. Dynamicdrive: Good Site For JavaScript Codes
    (5)
    If anyone needs Javascript codes or similar items for their web page a great place to go is
    http://www.dynamicdrive.com . They have hundreds of codes that are good. I would reccomend them for
    all your javascript needs.....
  23. Browser Quaker Script - Shock Your Visitors!
    this script shakes the browser like a quake happened! (5)
    Browser Quaker! SHOCK your visitors! this script shakes the browser like a quake
    happened! yeah....try this script to believe it! im sure u will be stunned at the
    effect! a good way to show your visitor that...your website ROCKS!..and literally so !
    ! i got this script from Bravenet 's webmaster freebrees newsletter. if you haven't
    known bravenet before..it is a beginner webmaster's friend! you get lot many features for
    your website hosted freely. and subscribe to their newsletter to get gems like these! ok
    here'....
  24. Change Table Colors On Mouse Effects!
    create onMouseover/onMouseout color effects within tables! (8)
    Source: http://www.cgiscript.net/cgi-script/csNews...wone&id=49&op=t stun ur visitors with
    changing table colors! QUOTE change table rows or table cells bgcolor when mouse moves over
    elements of the table. (works on IE only). QUOTE paste the following code into the table
    element that you want to change. for example, if you want to change the table row you paste the
    code into the . if you want to change a table cell color you paste the code on the . you may even
    add it to the tag to highlight the entire table! Code: QUOTE onMo....
  25. Dynamically Change The Background Image On Mouse Effects!
    easy code to dynamically change the background image (3)
    stun ur visitor with a new bg image on every mouse click of his! easy code to dynamically
    change the background image. Copied from
    http://www.scriptworm.com/scriptengine/visit.php?id=30296 QUOTE control the background image
    using the links on your site. control the color using onMouseOver, onMouseOut, onClick, and a
    combination of all of them. place the code below between the and tags within the HTML page where
    you want the link to appear. edit the link text provided to point at the page you would like to
    open. Option 1: use this to change the backgro....
  26. Javascript: Text To Texbox And Back To Text
    (2)
    i need some help i want to create a thing where when some one double clicks a certain text it
    changes into a texbox where they can edit the text and the they double click and it changes into the
    test they just typed in. I have found this function in javascript that does some of it but i needs
    to be simplified CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html> <head> <title>Span to Text Box - Demo - DOM</title> <scr....
  27. Best Way To Learn Javascript
    I would very much like to know. (9)
    Well, I know HTML, I know CSS, so the next step is learning Javascript. I have heard that it is sort
    of an easier way to do things than PHP, though I would very much like to learn PHP as well. So, I
    thought that if I learnt Javascript, I might find it easier to learn PHP when I get to that point.
    The problem though is actually finding out the best way to learn Javascript. I have been to
    websites and things, but every time I read through the tutorials and articles and things, I
    didn't learn anything. It when in one ear and out the other, you could say. So, that is wh....
  28. javascript vs java
    (12)
    in my opinion javascript is better then java becasue java requires more programing experecense
    then javascript and i think to that javascript is more reliable then java in some ways....
  29. How To Create A Popup Window With Javascript?
    (19)
    Please help me! I want to in popup massage suggest to visitors of my site to make my site their
    home page . Please note that I have some script code that visitors most click on a text to make my
    site their home page . Every one that can help me please send an email to soleimanian@noavar.com....
  30. Getting Screen Resolution using Javascript.
    (8)
    Is it possible to get the screen resolution of the users moniter using only javascript. No other
    external stuff, just pure javascript. I guess most of the people using JAVA for this. I also got
    some scripts regarding this which used SCREEN.WIDTH function or something, but they did not seem to
    work out. Any possible solutions. BTW, is it possible to get the resolution using PHP ( I guess it
    is not ) .......

    1. Looking for javascript, disable, mouse, click, browser

Searching Video's for javascript, disable, mouse, click, browser
Similar
Javascript
Changes
Aren't
Working.
Javascript
Help Needed
: Alert(z)
Works Fine
But
Document.wri
te Not -
please
When A User
Close The
Browser
Window - How
to control
this action
Fun With
Javascript
And Forms -
Lets have
some fun
with
javascript&#
33;
Include
Function For
Javascript
Problem With
Javascript
Alert();
Get Mouse
Position
Javascript:
How Do I
Create
Embedded
Pop-up
Windows?
Javascript
Question -
Vertical
Scroll Box
Add Text To
Textarea - I
suppose it
uses DOM and
JavaScript??
One Click To
Copy Script
- Works in
IE6 but not
any other
Browsers
Problems
With
Dynamically
Loading
Javascript -
As well as
dynamically
inserting
HTML
I Need Help
With
Javascript.
- help plz
JavaScript
Off Redirect
Script - How
to redirect
a browser
when
Javascrip
JavaScript
Frames &
Querystring
Vertical
Marquee
Using
JavaScript -
by The
JavaScript
Source
Create And
Import
JavaScript
Modules For
A Large
Script
Ever Needs
To Find Out
A Table
Height Or
With With
JavaScript -
Well stop
looking,
here is the
answer (CSS
and JS)
JavaScript:
Hide And
Show Any
Element With
CSS - From
the simple
way to the
more
advanced way
(Javascript
& CSS)
JavaScript:
Simple
Dropdown
Menu -
Simple
Dropdown
Menu
Javascript:
Simple
Slidedown
Menu -
Simple
Slidedown
Menu
Dynamicdrive
: Good Site
For
JavaScript
Codes
Browser
Quaker
Script -
Shock Your
Visitors!
; - this
script
shakes the
browser like
a quake
happened!
;
Change Table
Colors On
Mouse
Effects!
- create
onMouseover/
onMouseout
color
effects
within
tables!
Dynamically
Change The
Background
Image On
Mouse
Effects!
- easy code
to
dynamically
change the
background
image
Javascript:
Text To
Texbox And
Back To Text
Best Way To
Learn
Javascript -
I would very
much like to
know.
javascript
vs java
How To
Create A
Popup Window
With
Javascript?
Getting
Screen
Resolution
using
Javascript.
advertisement




Javascript: Disable Mouse Right-click In Browser



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE