Capture right-click event?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Oschler

    Capture right-click event?

    Hello,

    In my web pages I attach the OnClick event. However this doesn't seem to
    intercept right-click events. Is there another event I need to attach or is
    it something else?

    thx

    --
    Robert Oschler
    http://www.dog-images.com -- Devoted to providing free info on the health,
    nutrition, and training of dogs.



  • Brynn

    #2
    Re: Capture right-click event?


    I know how to do it .. but I don't agree with the practice or ability
    of it.
    sorry,

    Brynn


    On Sat, 24 Jan 2004 00:57:34 -0500, "Robert Oschler"
    <no_replies@fak e_email_address .invalid> wrote:
    [color=blue]
    >Hello,
    >
    >In my web pages I attach the OnClick event. However this doesn't seem to
    >intercept right-click events. Is there another event I need to attach or is
    >it something else?
    >
    >thx
    >
    >--
    >Robert Oschler
    >http://www.dog-images.com -- Devoted to providing free info on the health,
    >nutrition, and training of dogs.
    >
    >
    >[/color]

    Brynn


    I participate in the group to help give examples of code.
    I do not guarantee the effects of any code posted.
    Test all code before use!

    Comment

    • Evertjan.

      #3
      Re: Capture right-click event?

      Brynn wrote on 24 jan 2004 in comp.lang.javas cript:[color=blue]
      > I know how to do it .. but I don't agree with the practice or ability
      > of it.
      > sorry,[/color]

      While not all functions are advisable for a public page,
      special rightclicking can be very useful.

      I have a personal page for housekeeping a database.
      This page is IP specific and password protected.
      Leftclicking on a record makes that record accessable for maintenance.
      Rightclicking is for deleting the record after confirm().

      [The easy thing for a personal page is that you write only for your own
      browser, IE6 in my case]

      <div class=myrecord
      onclick="leftcl ickfunction(thi s)"
      oncontextmenu=" rightclickfunct ion(this)"[color=blue]
      > ....[/color]



      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Martin Honnen

        #4
        Re: Capture right-click event?



        Robert Oschler wrote:
        [color=blue]
        > In my web pages I attach the OnClick event. However this doesn't seem to
        > intercept right-click events. Is there another event I need to attach or is
        > it something else?[/color]

        You can use the onmousedown event handler and check which mouse button
        has been pressed, however most people asking for right click are looking
        to intercept the context menu being requested, IE5+ and Netscape 6/7
        allow that with the
        oncontextmenu
        handler
        --

        Martin Honnen


        Comment

        • Jason Daviau

          #5
          Re: Capture right-click event?

          The event you are looking for is onContextMenu.

          Ex
          onContextMenu=" return YourMethod('You r Params')"

          Make sure your method returns false or the ie menu will still appear.


          "Robert Oschler" <no_replies@fak e_email_address .invalid> wrote in message
          news:YuqdndgpRI BylY_dRVn-jw@adelphia.com ...[color=blue]
          > Hello,
          >
          > In my web pages I attach the OnClick event. However this doesn't seem to
          > intercept right-click events. Is there another event I need to attach or[/color]
          is[color=blue]
          > it something else?
          >
          > thx
          >
          > --
          > Robert Oschler
          > http://www.dog-images.com -- Devoted to providing free info on the health,
          > nutrition, and training of dogs.
          >
          >
          >[/color]


          Comment

          • Grant Wagner

            #6
            Re: Capture right-click event?

            That code makes me glad I have a scriptlet on my Links toolbar that does:

            javascript:void (function
            (){document.bod y.oncontextmenu =null;window.on mousedown=null; window.onmouseu p=null;}());

            So when I do find myself surfing the Web with IE (because of the horrible design
            of some sites which make it almost impossible to view the site with anything
            other then IE), I can disable the author's misguided attempts to "help me out"
            by messing with the functionality of my browser.

            Jason Daviau wrote:
            [color=blue]
            > The event you are looking for is onContextMenu.
            >
            > Ex
            > onContextMenu=" return YourMethod('You r Params')"
            >
            > Make sure your method returns false or the ie menu will still appear.
            >
            > "Robert Oschler" <no_replies@fak e_email_address .invalid> wrote in message
            > news:YuqdndgpRI BylY_dRVn-jw@adelphia.com ...[color=green]
            > > Hello,
            > >
            > > In my web pages I attach the OnClick event. However this doesn't seem to
            > > intercept right-click events. Is there another event I need to attach or[/color]
            > is[color=green]
            > > it something else?
            > >
            > > thx
            > >
            > > --
            > > Robert Oschler
            > > http://www.dog-images.com -- Devoted to providing free info on the health,
            > > nutrition, and training of dogs.[/color][/color]

            --
            | Grant Wagner <gwagner@agrico reunited.com>

            * Client-side Javascript and Netscape 4 DOM Reference available at:
            *


            * Internet Explorer DOM Reference available at:
            *
            Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


            * Netscape 6/7 DOM Reference available at:
            * http://www.mozilla.org/docs/dom/domref/
            * Tips for upgrading JavaScript for Netscape 7 / Mozilla
            * http://www.mozilla.org/docs/web-deve...upgrade_2.html


            Comment

            Working...