469,573 Members | 1,551 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Anchor element follows HREF even though onClick returns false

I have a page with a button that has the following link:

<a href="/somelink?org.apache.struts.taglib.html.TOKEN=ef9f9 f5973be37ffe39c60227f402770#"
onclick="javascript:go( event, 'myForm');return false;">

The go() function submits a form and returns false. This is definately
working.

The problem is that on some peoples' computers ( only a rare few, that
have different OS's and browsers ) this link follows the HREF and goes
to "/somelink?..." instead of proceeding to the action inside of the
form.

I've identified that a fix to this problem is to replace to
'href="/somelink?..."' with 'href=#', though I don't know why this is
only a problem on some computers.

Has anyone else seen this in the past? I'm thinking there might be an
issue with popup-blockers... or some other third-party software.

Any information would be appreciated, thanks.
Jul 20 '05 #1
4 9706
"Johnny" <ja*********@yahoo.com> wrote in message
news:64**************************@posting.google.c om...
<snip>
onclick="javascript:go( event, 'myForm');return false;">

The go() function submits a form and returns false. This is
definately working.
The - go - function is a one of yours?
The problem is that on some peoples' computers ( only a rare
few, that have different OS's and browsers ) this link follows
the HREF and goes to "/somelink?..." instead of proceeding to
the action inside of the form.

<snip>

If an error occurs within the - go - function then JavaScript execution
will terminate and the event handling function will not return a value.
So the navigation within the HREF will be followed (that will also be
the case when JavaScript is not available on the client).

Obviously without seeing the code within the - go - function, or the
HTML it is interacting with, speculating as to whether, or how, it might
be erroring would be futile.

Richard.
Jul 20 '05 #2
In article <64**************************@posting.google.com >, jazzman_
33*@yahoo.com enlightened us with...
I have a page with a button that has the following link:

<a href="/somelink?org.apache.struts.taglib.html.TOKEN=ef9f9 f5973be37ffe39c60227f402770#"
onclick="javascript:go( event, 'myForm');return false;">

Don't put "javascript:" in an event handler. An event handler is already
script.
The go() function submits a form and returns false. This is definately
working.


Is it working in the problem browsers/OSs?
See Richard's post. If it's broken in some situations and "go" is
undefined (which is what happens in some browsers when a function has an
error), the browser may ignore the function.

If taking out the href were an option, why is it there?
Most of us put it there to support old browsers or browsers with no
script. If you don't need it (intranet, cd, etc), don't use it.

--
--
~kaeli~
Support your local medical examiner: die strangely!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3
kaeli <ti******@NOSPAM.comcast.net> wrote in message news:<MP************************@nntp.lucent.com>. ..
In article <64**************************@posting.google.com >, jazzman_
33*@yahoo.com enlightened us with...
I have a page with a button that has the following link:

<a href="/somelink?org.apache.struts.taglib.html.TOKEN=ef9f9 f5973be37ffe39c60227f402770#"
onclick="javascript:go( event, 'myForm');return false;">


Don't put "javascript:" in an event handler. An event handler is already
script.
The go() function submits a form and returns false. This is definately
working.


Is it working in the problem browsers/OSs?
See Richard's post. If it's broken in some situations and "go" is
undefined (which is what happens in some browsers when a function has an
error), the browser may ignore the function.

If taking out the href were an option, why is it there?
Most of us put it there to support old browsers or browsers with no
script. If you don't need it (intranet, cd, etc), don't use it.

--


Thank you both for your posts.

The reason I didn't provide the source to the go() function is that it
is not even getting executed. When the user click's the image this
anchor tag wraps, the go() function is not even being executed, the
browser follows the HREF immediately.

Kaeli, to answer your first question, yes, everything works on the
problem browser/OS after replacing the HREF with '#'. But, the
interesting part is that without replacing the HREF, everything works
on the same OS/browser on other machines. For some reason, this
machine is different, and that's what I'm trying to nail down... what
could be different? I was hoping that it would be a popup blocker, but
I was unable to find one.

To answer your second question, there is no logical reason for the
HREF to be there. I'm just troubleshooting the issue, but after
speaking with the developers, it seems that the HREF really has no
value. So, it will be removed either way.
Jul 20 '05 #4
In article <64**************************@posting.google.com >, jazzman_
33*@yahoo.com enlightened us with...

Kaeli, to answer your first question, yes, everything works on the
problem browser/OS after replacing the HREF with '#'. But, the
interesting part is that without replacing the HREF, everything works
on the same OS/browser on other machines. For some reason, this
machine is different, and that's what I'm trying to nail down... what
could be different? I was hoping that it would be a popup blocker, but
I was unable to find one.


I wouldn't think so, as most popup blockers I know of only block popups
that were NOT the direct result of a user action (IE). That is, if a
function from onClick opens a window, it's cool. If a function calls
another function that opens a window, it's blocked.
This is IME from using the blockers, so I could be totally off base
here.

I wonder if the browser settings are the same...
--
--
~kaeli~
Jesus saves, Allah protects, and Cthulhu thinks you'd make
a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Stanimir Stamenkov | last post: by
8 posts views Thread by saif | last post: by
11 posts views Thread by yawnmoth | last post: by
9 posts views Thread by Jan Eliasen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.