/    Sign up×
Community /Pin to ProfileBookmark

I need help with a div that triggers javascript on a seccond mouse button…

i need help to make a div on seccond mouse button that triggers a script, can anyone help me with this.

Baisicly, i have a standered div with an id of ‘test’:

[code=html]<div id=”test”>This is a test div.</div>[/code]

All i want to do is to use javascript to trigger a function when the user seccond mouse-buttons on the div (and only that div)

Heres a [I]really[/I] baisc example:

[code=html]<script>
function divclick() {
alert(‘you seccond mouse-buttoned on this div.’);
}
</script>[/code]

Could someone please help…

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@KorApr 07.2005 — use [b]oncontextmenu[/b] event handler

[code=php]
<div id="test" oncontextmenu="alert('you seccond mouse-buttoned on this div.')">This is a test div.</div>
[/code]
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 08.2005 — Oh thank you soo much ?
Copy linkTweet thisAlerts:
@KorApr 08.2005 — I hope that you will use it wisely. As a user, I would like my default right-click mouse behaviour [b]not[/b] to be changed, except for strong and good reasons...
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 09.2005 — lol, what i am doing is on this div, replacing the standered right-click menu with one of my own. Thanks for your help again.
Copy linkTweet thisAlerts:
@felgallApr 09.2005 — You need to remember that some browsers (eg. Opera) ignore any attempts to override the standard context menu functioning and that your script will not work for anyone using that browser.
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 10.2005 — ok sure thing, thanks for that felgall, ill make is so it only shows up in specific browsers. Again, thanks for all your help you guys.
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 11.2005 — one more quick question, is there a way of disabling the seccond mouse button menu? because it is getting in the way of my script
Copy linkTweet thisAlerts:
@KorApr 11.2005 — oncontextmenu="somefunction();[color=red]return false[/color]"
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 11.2005 — Ya, i just worked that out myself.

Anyways thanks again.
Copy linkTweet thisAlerts:
@KorApr 11.2005 — That means u are at least as smart as I was when joining first time this forum... ?
Copy linkTweet thisAlerts:
@robo_neojetsamauthorApr 13.2005 — Yeah, i wish i was smarter, but i guess im learning ?
×

Success!

Help @robo_neojetsam 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.26,
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,
)...