/    Sign up×
Community /Pin to ProfileBookmark

No "Right-Clicking" Here

I tried using this code to disable right clicking on a test page:

<script language=JavaScript>
<!–

//Disable right click script III- By Renigade ([email protected])
//For full source code, visit [url]http://www.dynamicdrive.com[/url]

var message=””;
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function(“return false”)
// –>
</script>

It doesnt’ work, not on IE version 6 anyways. Does anybody out there have a better solution for this feature?

thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Apr 30.2003 — its not a permanent solution,

its simply a nuisance,why bother with it...
Copy linkTweet thisAlerts:
@kbocaletApr 30.2003 — I haven't tested it with netscape but it works on IE.

<script LANGUAGE="JavaScript">

<!-- Original: Martin Webb ([email protected]) -->

<!-- This script and many more are available free online at -->

<!-- The JavaScript Source!! javascript.internet.com -->


function right(e)

{

&nbsp;&nbsp;if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;

&nbsp;&nbsp;else

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert("Disabled Option.");

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;

}

document.onmousedown=right;

document.onmouseup=right;

if (document.layers) window.captureEvents(Event.MOUSEDOWN);

if (document.layers) window.captureEvents(Event.MOUSEUP);

window.onmousedown=right;

window.onmouseup=right;

</script>

I know there is an easier way with oncontextmenu, you should try to search for that on previous threads, I think I saw it yesterday but not really sure...

Karla
Copy linkTweet thisAlerts:
@ShampieApr 30.2003 — <script>

function click(e){if (document.all) if (event.button == 2) return false;if

(document.layers) if (e.which == 3) return false;}

function click2(){event.returnValue=false;return false;}if (document.layers)

document.captureEvents(Event.MOUSEDOWN);document.onmousedown=click;document.oncontextmenu=click2;

</script>

when users rightclicks nothing will happen. (no menu or any msg)
×

Success!

Help @fuxmyl spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...