Grant Ord
"Grant Ord" <gran...@nospam.nospam> wrote in message
news:57A7D51F-0E28-48C0...@microsoft.com...
You'll soon be told by others that you can't disable the right-click and
that you can't hide your source code.
Here's two techniques which seem to work on some browsers; IE at least.
<html>
<head>
<title>noright1.htm</title>
</head>
<body oncontextmenu="return false">
</body>
</html>
This one tricks the user in to thinking that right-click is disabled. It
can be defeated by keeping the right mouse button down while pressing the
Enter key.
<html>
<head>
<title>noright2.htm</title>
<script type="text/javascript">
function click() {
if (event.button == 2) alert('This function has been disabled.')
}
document.onmousedown = click;
</script>
</head>
<body>
</body>
</html>
Keep checking back -- others will have a lot to say!
Just take a look at the post in comp.lang.javascript entitled "Disable
right-click without alert?".
"McKirahan" <Ne...@McKirahan.com> wrote in message
news:10Z5d.166578$3l3.35668@attbi_s03...
We are building web based applications where a right click opens the
application's context-menu. So there actually are situations where
blocking the default-behaviour might make sense.
Daniel
It seems polite to have the first option of that menu returning true, to be
able to use the rightclick functions, or to implement only alt-rightclick
to your menu:
<body
oncontextmenu="if(event.altKey){menu();return false};return true;'>
[I think there is more to it for non IE?]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)
So you think that changing the default behavior, that people have become
adjusted to, "might make sense"? It doesn't.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Sorry I did give feedback.
In the end I'm using all this lot and it seems to work.
I've also disabled dragging - outside of from boxes.
There is no need for it in my application and it prevents that horibble
highlighting you I get when I select inavertantly - I seem to suffer from it
with laptop touch pads and it drives me mad!
function oncontextmenuDocument() {
window.event.returnValue = false;
alert('This feature is not available on this site.');
}
function onmousedownDocument() {
if (window.event.button == 2) {
window.event.returnValue = false;
alert('This feature is not available on this site.');
}
}
function ondragstartDocument() {
with (window.event) {
if (srcElement.type) {
with (window.event.srcElement) {
if (!(type == 'text' || type == 'textarea')) {
returnValue = true;
return;
}
}
}
returnValue = false;
}
}
function onselectstartDocument() {
with (window.event) {
if (srcElement.type) {
with (window.event.srcElement) {
if (!(type == 'text' || type == 'textarea')) {
returnValue = true;
return;
}
}
}
returnValue = false;
If the site is for an intranet, where you can control the setup of the
computers, then you can attempt to disable the mouse. Otherwise, you are
spinning your tail and no amount of script on the web will disable my
right mouse button. Mozilla and Opera both allow me to stop you from
disabling it.
I tried the first option of using oncontextmenu in body tag.
It works everywhere except at the extreme edges.Means when I right click
around or near to the edges, the view source menu is popping out.
What should I do to prevent it?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
> I tried the first option of using oncontextmenu in body tag.
> It works everywhere except at the extreme edges.Means when I right click
> around or near to the edges, the view source menu is popping out.
> What should I do to prevent it?
Put the oncontextmenu on the html element or remove margin on the body
element.
(And, as you have probably been told before, it's only something one
should do in controlled environments. For internet use, disableing the
context menu is just a big sign saying "Eirher I am clueless or I
don't want visitiors" :)
/L
--
Lasse Reichstein Nielsen - l...@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
> JohnDpatriot said:
>>Add this script to the top of the page (will only work with IE)
>
>
> I'm curious as to the circumstances in which hiding code from
> IE users only (and only if scripting is enabled) is useful.
>
In our organization we only allow IE and we use config scripts to ensure
that all IE clients are the same
Thanks a lot...Its working...
Hope it satisfies my client.