473,322 Members | 1,523 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,322 software developers and data experts.

How to get right mouse botton click on image

Hello,

I am trying to capture a right mouse button click on an image.

So far I am getting the left click with

<body onload="document.getElementById('image').onclick=e ventclick;">
<image align=center image border=2 img src="data.jpg" id="image">

How can I detect the right mouse click on this image?

Thanks so much!

May 10 '06 #1
3 5243
Dustin Carroll wrote:
Hello,

I am trying to capture a right mouse button click on an image.

So far I am getting the left click with

<body onload="document.getElementById('image').onclick=e ventclick;">
<image align=center image border=2 img src="data.jpg" id="image">

How can I detect the right mouse click on this image?

Thanks so much!


Try this:

<body onload="document.getElementById('image').onclick=e ventclick;">
<image align=center image border=2 img src="data.jpg" id="image"
oncontextmenu="showContextualMenu()">

Hope that helps :)

May 10 '06 #2
Dustin Carroll wrote:
I am trying to capture a right mouse button click on an image.

So far I am getting the left click with

<body onload="document.getElementById('image').onclick=e ventclick;">
<image align=center image border=2 img src="data.jpg" id="image">

How can I detect the right mouse click on this image?


<img
onContextMenu="return false;"
onMouseDown="if (event.button==2) alert('image was right-clicked');"
border="2"
src="data.jpg">

--
Bart

May 10 '06 #3
Bart Van der Donck wrote:
Dustin Carroll wrote:
<body onload="document.getElementById('image').onclick=e ventclick;">
<image align=center image border=2 img src="data.jpg" id="image">

How can I detect the right mouse click on this image?


<img
onContextMenu="return false;"
onMouseDown="if (event.button==2) alert('image was right-clicked');"
border="2"
src="data.jpg">


Due to the proprietary `oncontextmenu' attribute, that is invalid HTML as
well. AFAIS, the right mouse click can be detected this way in Geckos too,
but display of the context menu cannot be prevented whatsoever (and that is
good so). In case this is just another misguided attempt at preventing
users from downloading the image, please don't, and search the group
archives instead.
PointedEars
May 21 '06 #4

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

Similar topics

2
by: Wonko | last post by:
Here's my problem if anyone could be so kind to help me out. I assume it's quite easy for an experienced programmer but I'm not one of them :) I have a JavaScript code that: - displays multiple...
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...
8
by: Alpenvrouwtje | last post by:
Hallo, Does anyone have a (simple?) javascript code for me to prevent that people take the photo's of my website while they use the right mouse button. I know that there are ways around this...
3
by: Gary Mayor | last post by:
Hi, I'm re phrasing and earlier question as the earlier question doesn't make to much sense. I using document.onmousemove to move a <div line on the screen. At the moment if I click and move the...
4
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
2
by: Sean | last post by:
Hi, I have a treeview and user can right click the treenodes, depending on the nodes, different shortcut menu will appear. I want only the shortcut menu to appear if the point of the right...
0
by: StriderBob | last post by:
In a simple two form project, use a button on each form to Show() the other form and Hide() the current form. Add MouseEnter and MouseLeave events to both buttons so they change the image on each...
2
by: rustysbrowne | last post by:
how to get a mouse click on a color well strate to the point i need a code that will get a mouse to click on a botton with a certon color on it
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.