Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #14209

Re: When is onclick *not* triggered?

Message-ID <2017556.lXCzD688iH@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-05-29 17:40 +0200
Subject Re: When is onclick *not* triggered?
Newsgroups comp.lang.javascript
References <gep9s7pei50vqjmuoerjb96lbvf1huknt7@4ax.com>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Tim Slattery wrote:

> We have a legacy app that uses a somewhat odd method of submitting a
> page, and it's giving us fits.
> 
> There's no "<input type='submit'...> button on the page. What is there
> is an image of a "Continue" arrow surrounded in an <a ... > tag. Here
> it is:
> 
>    <a href="" onclick="submit_page(contactForm, 'prices');return
> false;"
>       title="Continue through the Web site" scope="request" >
>          <img border="0" src="/GlobalContent/images/arrowContinue.gif"
> align="middle"/>
>    </a>

And invalid markup on top of that.  I have seen such nonsense before in my 
job as well.

> The "submit_page" script sets a couple of values and submits the form
> Works just fine,  nearly always.

See below.

> The problem is that in a very few cases, it looks like the href tag is
> activated (for lack of a better term)

The better (and correct) wording would be "the `A' element is activated".  
`href' is not a tag, it is an attribute (name).

> without triggering the onclick.

Unlikely, but possible.

> The result is that the page is submitted to a nonexistent address.

Incorrect.  `""' is a same-document reference.  As a result, there is a race 
condition if the `click' event is not canceled (which is short for "the 
default action of the `click' event is not prevented", see 
preventDefault()).
 
> So my question is how could this happen?

Client-side scripting is not supported or the submit_page() call throws an 
exception.  You do not handle that exception, which is why the program 
aborts.  If it aborts, usually the `onclick' attribute value is processed as 
if it was not there.

> The errors seem to be reported by people using IE8. I've run my tests
> with that browser and haven't turned up anything.

The nature of a race condition is that it is not reproducible or hard to 
reproduce.  Replace the legacy approach, and fix your function, so that 
there is no race condition.


PointedEars
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

When is onclick *not* triggered? Tim Slattery <Slattery_T@bls.gov> - 2012-05-29 11:15 -0400
  Re: When is onclick *not* triggered? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-29 17:40 +0200
  Re: When is onclick *not* triggered? Richard Cornford <Richard@litotes.demon.co.uk> - 2012-05-29 08:47 -0700
  Re: When is onclick *not* triggered? "Tom de Neef" <tdeneef@qolor.nl> - 2012-05-29 23:02 +0200

csiph-web