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


Groups > comp.lang.javascript > #14209

Re: When is onclick *not* triggered?

Path csiph.com!usenet.pasdenom.info!news.albasani.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="ISO-8859-1"
Message-ID <2017556.lXCzD688iH@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Tue, 29 May 2012 17:40:08 +0200
User-Agent KNode/4.4.11
Content-Transfer-Encoding 7Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: When is onclick *not* triggered?
Newsgroups comp.lang.javascript
References <gep9s7pei50vqjmuoerjb96lbvf1huknt7@4ax.com>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 62
NNTP-Posting-Date 29 May 2012 17:40:09 CEST
NNTP-Posting-Host 906de3ff.newsspool4.arcor-online.net
X-Trace DXC=9]l5b=iLEDH=8m7nZkdN^@4IUK<Cl32<A4Fo<]lROoRA8kF<OcfhCOK?F<P;FJ26_BDZm8W4\YJNLJ`:FmdeL>K@U@3`]Ai;BfBjhe::FKZX]M
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:14209

Followups directed to: comp.lang.javascript

Show key headers only | 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