/    Sign up×
Community /Pin to ProfileBookmark

Event handler

Hi,

onclick is the event handler for left mouse click, what is the event handler for right mouse click?

Thanks,

Neil

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryJul 17.2003 — According to the [url=http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/handlers.html#1119876]Netscape JS reference[/URL], it is still onclick. You can test which button was pressed using the which property. (1 for left button, 3 for right button).

Adam
Copy linkTweet thisAlerts:
@neil9999authorJul 18.2003 — Thanks, but i don't understand how to specify '3'. Could you show me an example script, please, where when you right click on a link an alert appears?

Thanks again,

Neil
Copy linkTweet thisAlerts:
@neil9999authorJul 18.2003 — Thanks,

I tried adapting it to open a popup when you right click on the page.

What's wrong with this?

<html>

<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

function NewWindow(mypage, myname, w, h, scroll) {

var winl = (screen.width - w) / 2;

var wint = (screen.height - h) / 2;

winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'

win = window.open(mypage, myname, winprops)

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}

// End -->

</script>

<title>New Page 1</title>

<script language=JavaScript>

<!--

//Disable right mouse click Script

//By Maximus ([email protected]) w/ mods by DynamicDrive

//For full source code, visit http://www.dynamicdrive.com


///////////////////////////////////

function clickIE4(){

if (event.button==2){

function NewWindow(this.href, name, 500, 500, yes);

return false;

}

}

function clickNS4(e){

if (document.layers||document.getElementById&&!document.all){

if (e.which==2||e.which==3){

function NewWindow(this.href, name, 500, 500, yes);

return false;

}

}

}

if (document.layers){

document.captureEvents(Event.MOUSEDOWN);

document.onmousedown=clickNS4;

}

else if (document.all&&!document.getElementById){

document.onmousedown=clickIE4;

}

document.oncontextmenu=new Function("alert(message);return false")

// -->

</script>

</head>

<body>

</body>

</html>

Neil
×

Success!

Help @neil9999 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 6.14,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...