Two events firing! (return FALSE;?)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin Hale

    Two events firing! (return FALSE;?)

    I have a problem (amongst others)...
    I have the following code which sends 2 emails. I only want to send
    one!

    <A
    ONCLICK="OnActi onClick('E-Mail')"
    ID="EMailNowAnc hor"
    NAME="EMailNowA nchor"
    HREF="javascrip t:OnActionClick ('E-Mail');"
    TABINDEX ="2"
    CLASS="Button">
    <IMG SRC="images/email.gif" ALT="Click Here" BORDER="0"
    ALIGN="ABSMIDDL E">
    E-Mail Now</A>

    The trouble is that both the HREF and the OnClick are triggered and 2
    mails are send instead of just 1.

    I've tried replacing my HREF line with

    HREF="javascrip t:OnActionClick ('E-Mail');return FALSE"

    but this just gives an error 'return statement outside of function'.

    I thought you could prevent event propogation/bubbling with return
    false?

    Any ideas?
  • Martin Honnen

    #2
    Re: Two events firing! (return FALSE;?)



    Colin Hale wrote:
    [color=blue]
    > I have a problem (amongst others)...
    > I have the following code which sends 2 emails. I only want to send
    > one!
    >
    > <A
    > ONCLICK="OnActi onClick('E-Mail')"
    > ID="EMailNowAnc hor"
    > NAME="EMailNowA nchor"
    > HREF="javascrip t:OnActionClick ('E-Mail');"
    > TABINDEX ="2"
    > CLASS="Button">
    > <IMG SRC="images/email.gif" ALT="Click Here" BORDER="0"
    > ALIGN="ABSMIDDL E">
    > E-Mail Now</A>
    >
    > The trouble is that both the HREF and the OnClick are triggered and 2
    > mails are send instead of just 1.[/color]

    Well, then use
    <a href="#"
    onclick="OnActi onClick('E-Mail');
    return false;"[color=blue]
    >
    > I've tried replacing my HREF line with
    >
    > HREF="javascrip t:OnActionClick ('E-Mail');return FALSE"
    >
    > but this just gives an error 'return statement outside of function'.
    >
    > I thought you could prevent event propogation/bubbling with return
    > false?
    >[/color]

    You can cancel the default action of some events with
    return false;
    However a href is a link and not an event handler.

    --

    Martin Honnen


    Comment

    Working...