473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to disable right click menu in IE, Netscape 4 and Netscape 6

This explains how to disable the view source / right-click menu in
Netscape 4, Netscape 6 and Internet Explorer (IE).

<script language="JavaScript">
//This code is the beginning of the right click disable
function right(e) {
//This function is for Net 4.
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which ==
2))
{
return false;
}
return true;
}

function context(){
//This function takes care of Net 6 and IE.
return false;
}

document.onmousedown=right;
document.oncontextmenu=context;
</script>

Note: If you set up a frame page, and in each frame include the above
code, the casual user will not be able to view the source. If you use
frames, the browser menu option "View Source" will only view the main
frame page source, not the individual frame source. However, any
sophisticated user will be able to still view all the source simply by
turning off javascript, or by using a browser that doesn't recognize
this script.

Note: Only tested on a Windows XP machine, run at your own risk. You
may need to tweak the code for other platforms/browers, but you can
get the idea from this sample.

The reason I'm posting this is that it is very difficult for a novice
to find this information on the Net, as an immense amount of posts
declare this as impossible, and an equally immense amount of posts
scathingly denounce this as the worst thing you can do to a web page.
This post is for those people that simply want to meet a customer's
needs. Even if the request is a bad idea, customers still pay the
bills :)
Jul 20 '05 #1
11 13674
On 9 Jul 2003 07:53:00 -0700, ya*******@yahoo.com (yaktipper) wrote:
Note: Only tested on a Windows XP machine, run at your own risk. You
may need to tweak the code for other platforms/browers, but you can
get the idea from this sample.

The reason I'm posting this is that it is very difficult for a novice
to find this information on the Net,
Yet, you've not helped the novice, as you freely admit you've not
tested this beyond a couple of browsers (ignoring popular ones like
IE5)
as an immense amount of posts declare this as impossible,
I've never seen it declared impossible in the browsers you're talking
about, the groups FAQ even covers how to block the popup menu (it
doesn't cover NN4, but then NN4 is hardly used, compared with other
browsers your example doesn't cover)
This post is for those people that simply want to meet a customer's
needs. Even if the request is a bad idea, customers still pay the
bills :)


Yes, but customers judge you better if you do a good job, not the
uneducated bodge they asked for in the 1st place. Either way they
still pay the bill, but if they get a good job - they recommend you to
others.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2
Lee
ya*******@yahoo.com said:
Even if the request is a bad idea, customers still pay the
bills :)


How much do you charge for all night?

Jul 20 '05 #3
yaktipper wrote:
This explains how to disable the view source / right-click menu in
Netscape 4, Netscape 6 and Internet Explorer (IE).
Ineffective.
http://stone.thecoreworlds.net/www/hide/
The reason I'm posting this is that it is very difficult for a novice
to find this information on the Net
No, its easy: http://search.yahoo.com/bin/search?p=block+right+click
, as an immense amount of posts declare this as impossible
No they don't - they declare it useless and irritating.
and an equally immense amount of posts scathingly denounce this as the
worst thing you can do to a web page.
It isn't, but it certainly comes close.
This post is for those people that simply want to meet a customer's
needs


I thought it was for novices? Novices shouldn't have customers, they should
be learning.
--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #4
In article <be**************************@posting.google.com >,
ya*******@yahoo.com shared the illuminating thought...
<snip>
The reason I'm posting this is that it is very difficult for a novice
to find this information on the Net, as an immense amount of posts
declare this as impossible, and an equally immense amount of posts
scathingly denounce this as the worst thing you can do to a web page.
This post is for those people that simply want to meet a customer's
needs. Even if the request is a bad idea, customers still pay the
bills :)


You are very mean, taking money from the mentally challenged.
*G*

----------------------------------------
~kaeli~
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
----------------------------------------
Jul 20 '05 #5
While the city slept, yaktipper <ya*******@yahoo.com> feverishly typed:
This post is for those people that simply want to meet a customer's
needs. Even if the request is a bad idea, customers still pay the
bills :)


Ok. So ask your builder to build you a house. Tell him you don't want
foundations. Your builder will tell you that is a bad idea. You tell him
"But I'm paying the bill!". A good builder will politely point out that he
won't build a house without foundations as (building regulations, etc aside)
he has a reputation to think of. Do you want to be a good builder or a bad
builder?

Cheers,
Nige

--
Nigel Moss.

Email address is not valid. ni***@nigenetDOG.org.uk. Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
"How strange the change from major to minor..."
Jul 20 '05 #6
"yaktipper" <ya*******@yahoo.com> wrote in message
news:be**************************@posting.google.c om...
<snip>
The reason I'm posting this is that it is very difficult
for a novice to find this information on the Net,
Then perhaps the novices actually need instruction on how to type the
words "contextmenu" and "javascript" into a search engine. 2000+ hits at
google.com, though all of the scripts are as poor as the one you posted.
That is because by the time anyone has learnt enough to do a good job of
writing a context menu blocking script they have also learnt enough to
know why doing so is a waste of their effort.
as an immense amount of posts declare this as impossible,
No one has ever declared that using JavaScript to interfere with the UI
of a web browser is impossible, it is in fact trivial. They may have
stated that disabling the context menu on all browsers is impossible,
Opera has never allowed JavaScript to influence its contextmenu.

But more likely it is the goal that disabling the context menu is
intended to promote that is being described as impossible. That goal is
usually the concealing, protecting or obscuring of some implementation
detail of a web page (source code, image files, etc.). Achieving that
goal _is_100%_impossible_ because if a publicly accessible HTTP server
sends something in response to a request then that response is available
to the receiving client, from the binary stream coming down the wire
though to the resulting files. Everything at every stage, and the HTTP
server has no way of even knowing whether the requesting software is a
web browser.
and an equally immense amount of posts scathingly
denounce this as the worst thing you can do to a web page.
When it can be objectively determined that disabling a contextmenu both
cannot be done reliably and will not facilitate anything beyond the
inconvenience it causes to people who want (or, in the case of some
disabilities, need) to use the contextmenu it does not seem unreasonable
to assert that doing so is a bad idea. People who have suffered at the
hands of script author's bad ideas may express there distaste with
extreme words but that may just be an indicator of how bad an idea it
is.
This post is for those people that simply want to meet a
customer's needs.
That depends on what the customers need is. If they are after some sort
of protection, or concealment then disabling the context menu will not
deliver it. If you cannot deliver something that is asked for it makes
more sense to say so (and why it is impossible) than have a customer
discover later that you sold them just the illusion of security and not
the real thing.

On the other hand, if the customer's "need" is to randomly inconvenience
the visitors to their web site and restrict disabled access well there
are thousands of ways of doing that, crippling the browser's UI is
barely scratching the surface.
Even if the request is a bad idea, customers still pay the bills :)


If the request if for protection, concealment, security, etc., don't
fool yourself you cannot deliver, if the request is for a site that will
actively discourage visitors then fair enough, if they are willing to
pay then knock yourself out, a little work and you can probably
guarantee they get no visitors at all.

For the sake of balance, this is a javascript URL that can be bookmarked
and executed from the bookmark/favourites menu (or via drag-n-drop from
Start->Favourites if the browser has no Favourites menu available) and
will strip out the 'no contextmenu' script from the original post from
each and every frame in a frameset (or just an isolated page):-

javascript:void(function(fram){if((fram.frames)&&( fram.frames.length >
0)){for(var c =
fram.frames.length;c--;){arguments.callee(fram.frames[c]);};};try{docume
nt.oncontextmenu = null;document.onmousedown =
null;}catch(e){;}}(window));

Richard.
Jul 20 '05 #7
>>very difficult for a novice to find this information on the Net<<

Difficult for a novice? Anyone interested enough to right-click a page to
attempt to view source will be a novice for only about 10 more minutes. Or
however long it takes them open up Google and fiddle around with some
keywords.

Here's a method (there are others) to circumvent that type of script and
view the page source...
view-source:http://microsoft.com

View a external JavaScript file...
view-source:http://microsoft.com/homepage/toolbar.js

View a external css file...
view-source:http://microsoft.com/library/flyoutmenu/default.css

will only view the main frame page source, not the individual frame
source<<

Only true for IE; in Mozilla/Firebird you can right-click and get..."This
Frame"->"View Frame Source".

--
DWilliams
"yaktipper" <ya*******@yahoo.com> wrote in message
news:be**************************@posting.google.c om... This explains how to disable the view source / right-click menu in
Netscape 4, Netscape 6 and Internet Explorer (IE).

<script language="JavaScript">
//This code is the beginning of the right click disable
function right(e) {
//This function is for Net 4.
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which ==
2))
{
return false;
}
return true;
}

function context(){
//This function takes care of Net 6 and IE.
return false;
}

document.onmousedown=right;
document.oncontextmenu=context;
</script>

Note: If you set up a frame page, and in each frame include the above
code, the casual user will not be able to view the source. If you use
frames, the browser menu option "View Source" will only view the main
frame page source, not the individual frame source. However, any
sophisticated user will be able to still view all the source simply by
turning off javascript, or by using a browser that doesn't recognize
this script.

Note: Only tested on a Windows XP machine, run at your own risk. You
may need to tweak the code for other platforms/browers, but you can
get the idea from this sample.

The reason I'm posting this is that it is very difficult for a novice
to find this information on the Net, as an immense amount of posts
declare this as impossible, and an equally immense amount of posts
scathingly denounce this as the worst thing you can do to a web page.
This post is for those people that simply want to meet a customer's
needs. Even if the request is a bad idea, customers still pay the
bills :)

Jul 20 '05 #8
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:be*******************@news.demon.co.uk...
<snip>

Slight correction, the - document.onxxxxxx = null - lines should have
been prefexed with - fram. - or they won't remove the script from the
entire frameset :-

javascript:void(function(fram){if((fram.frames)&&( fram.frames.length >
0)){for(var c =
fram.frames.length;c--;){arguments.callee(fram.frames[c]);};};try{fram.d
ocument.oncontextmenu = null;fram.document.onmousedown =
null;}catch(e){;}}(window));

Richard.
Jul 20 '05 #9

These replies are mainly techspam, thanks for backing up my reason for
posting this in the first place.

For those that pointed out other places to find answers and code
examples, thank you.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #10
On Wed, 9 Jul 2003 18:40:36 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.uk> wrote:


When it can be objectively determined that disabling a contextmenu both
cannot be done reliably and will not facilitate anything beyond the
inconvenience it causes to people who want (or, in the case of some
disabilities, need) to use the contextmenu it does not seem unreasonable
to assert that doing so is a bad idea. People who have suffered at the
hands of script author's bad ideas may express there distaste with
extreme words but that may just be an indicator of how bad an idea it
is.

A small point - disabling the context menu, if it is essential to some
disabled users, may fall foul of legislation (e.g. US Section 508,
European Convention on Human Rights, Disability Discrimination Act in
the UK).

So, the professional should politely advise the client that not merely
is blocking the context menu useless and likely to irritate many
users, but may in many jurisdictions actually be illegal!

Paul
Jul 20 '05 #11
"Paul Cooper" <pa*********@Nobasspam.ac.uk> wrote in message
news:u4********************************@4ax.com...
<snip>
... (or, in the case of some disabilities, need) ...
<snip>
A small point - disabling the context menu, if it is essential
to some disabled users, may fall foul of legislation (e.g. US
Section 508, European Convention on Human Rights, Disability
Discrimination Act in the UK).

So, the professional should politely advise the client that
not merely is blocking the context menu useless and likely
to irritate many users, but may in many jurisdictions
actually be illegal!


Reading over my post yesterday I though that I should not have been so
definite in that statement as I don't remember the details. What I do
remember is reading someone's assertion that due to circumstances
pertinent to them as an individual they had a _need_ to use the context
menu. And I have a vague memory that those circumstances were disability
related.

I would tend to always take someone's assertions about themselves at
face value, but whether their perceived need to use the context menu was
I real need (i.e. there may be some other mechanism that would achieve
their goal but they were just not aware of it) I cannot say.

That might make it difficult to argue the case on the grounds of
disability legislation. But given, "unreliable", "useless" and
"irritating" the possibility of adding "may be interpreted as illegal
under some circumstances" should not be influencing the behaviour of a
professional. The decision should already have been made.

Richard.
Jul 20 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Lijun Yang | last post by:
Hey, I am able to disable the right mouse button on images for netscape and IE but it won't work for Opera. Here is the code: // start of the code var clickmessage="Sorry, you don't have...
6
by: nntp | last post by:
I have a set of links which I want search engines to crawl them, but I want to disable them from my visitors, so I will ask the link owners to pay me to let me enable them. <a disabled...
29
by: lori3laz | last post by:
How do you disable the right click>view source option on web pages so people can't view your coding and copy it? What's the html I need to include in my website to utilize this feature? Thank...
8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
3
by: Ryan Joseph So | last post by:
On textboxes when you right click the mouse button a menu will pop-up with undo,cut,copy,paste,delete,select all. How can i disable the menu so when i right click on the textbox no menu will...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
4
by: Seen | last post by:
This has probably been covered before but I can't seem to find it. I want to disable the user from using the right mouse button that brings up a windown menu of options. How's it done?????
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
5
by: neehakale | last post by:
language using: C#. platform for program: WINDOWS FORM I wnt to disable the right click for text boxes.And also want to diable the context menu. I have already disable the Minimize and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.