By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,928 Members | 1,580 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,928 IT Pros & Developers. It's quick & easy.

Two events firing! (return FALSE;?)

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

<A
ONCLICK="OnActionClick('E-Mail')"
ID="EMailNowAnchor"
NAME="EMailNowAnchor"
HREF="javascript:OnActionClick('E-Mail');"
TABINDEX ="2"
CLASS="Button">
<IMG SRC="images/email.gif" ALT="Click Here" BORDER="0"
ALIGN="ABSMIDDLE">
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="javascript: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?
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a


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

<A
ONCLICK="OnActionClick('E-Mail')"
ID="EMailNowAnchor"
NAME="EMailNowAnchor"
HREF="javascript:OnActionClick('E-Mail');"
TABINDEX ="2"
CLASS="Button">
<IMG SRC="images/email.gif" ALT="Click Here" BORDER="0"
ALIGN="ABSMIDDLE">
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.
Well, then use
<a href="#"
onclick="OnActionClick('E-Mail');
return false;"
I've tried replacing my HREF line with

HREF="javascript: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?


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
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.