How to get right mouse botton click on image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dustin  Carroll

    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="documen t.getElementByI d('image').oncl ick=eventclick; ">
    <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!

  • Volte

    #2
    Re: How to get right mouse botton click on image

    Dustin Carroll wrote:[color=blue]
    > 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="documen t.getElementByI d('image').oncl ick=eventclick; ">
    > <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![/color]

    Try this:

    <body onload="documen t.getElementByI d('image').oncl ick=eventclick; ">
    <image align=center image border=2 img src="data.jpg" id="image"
    oncontextmenu=" showContextualM enu()">

    Hope that helps :)

    Comment

    • Bart Van der Donck

      #3
      Re: How to get right mouse botton click on image

      Dustin Carroll wrote:
      [color=blue]
      > I am trying to capture a right mouse button click on an image.
      >
      > So far I am getting the left click with
      >
      > <body onload="documen t.getElementByI d('image').oncl ick=eventclick; ">
      > <image align=center image border=2 img src="data.jpg" id="image">
      >
      > How can I detect the right mouse click on this image?[/color]

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

      --
      Bart

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: How to get right mouse botton click on image

        Bart Van der Donck wrote:
        [color=blue]
        > Dustin Carroll wrote:[color=green]
        >> <body onload="documen t.getElementByI d('image').oncl ick=eventclick; ">
        >> <image align=center image border=2 img src="data.jpg" id="image">
        >>
        >> How can I detect the right mouse click on this image?[/color]
        >
        > <img
        > onContextMenu=" return false;"
        > onMouseDown="if (event.button== 2) alert('image was right-clicked');"
        > border="2"
        > src="data.jpg">[/color]

        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

        Comment

        Working...