rules for onclick?

Discussion in 'Javascript' started by murrayatuptowngallery, Jun 14, 2007.

  1. I would like to combine a snippet that captures mouse position with
    onclick to insert one axis of the mouse position into a variable for
    form use.

    I have the mouse position capture part ok.

    Tutorial examples of onclick only explore what the author thinks are
    typical uses of onclick.

    So I guess I need to study the rules (or ask) for onclick...

    What I envision, conceptually (what follows is not correct language-
    wise - just look at for concept for now, please).


    <A HREF="something"
    onClick="VAR A=mouseX)";</A>

    If mouse is clicked, I want one of the mouse position variables
    defined by a separate mouse capure script insered into another
    variable.

    Can this be done, and is the HTML or JavaScript standard entry for
    onclick the place to learn the rules for this, or is it a
    combinational function that I will no find documentation on?

    Thank you

    Murray
     
    murrayatuptowngallery, Jun 14, 2007
    #1
    1. Advertising

  2. On Jun 14, 12:08 am, murrayatuptowngallery
    <> wrote:
    > <A HREF="something"
    > onClick="VAR A=mouseX)";</A>


    <button onclick="var a=event.clientX">Click me to set the value of
    variable a</button>

    > If mouse is clicked, I want one of the mouse position variables
    > defined by a separate mouse capure script insered into another
    > variable.
     
    scripts.contact, Jun 14, 2007
    #2
    1. Advertising

  3. Thank you
     
    murrayatuptowngallery, Jun 15, 2007
    #3
  4. murrayatuptowngallery

    RobG Guest

    On Jun 14, 4:20 pm, "scripts.contact" <>
    wrote:
    > On Jun 14, 12:08 am, murrayatuptowngallery
    >
    > <> wrote:
    > > <A HREF="something"
    > > onClick="VAR A=mouseX)";</A>

    >
    > <button onclick="var a=event.clientX">Click me to set the value of
    > variable a</button>


    I think you need to be a little careful about that. In some browsers,
    the result might be a global variable (window.a) but in others a might
    be local to the anonymous function assigned to the onclick handler.

    It is probably OK to prototype stuff using script inside an HTML
    attribute value, but for robustness they should be restricted to
    function calls or simple statements like "return false".

    --
    Rob
     
    RobG, Jun 15, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. thaneesh

    Code formatting rules in editor

    thaneesh, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,191
    thaneesh
    Jul 2, 2003
  2. Paul Johnson

    Business Rules & Referential Integrity

    Paul Johnson, Nov 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    597
    Paul Johnson
    Nov 20, 2004
  3. bob
    Replies:
    3
    Views:
    241
  4. Replies:
    2
    Views:
    285
  5. Replies:
    4
    Views:
    216
Loading...

Share This Page