Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14207 > unrolled thread
| Started by | Tim Slattery <Slattery_T@bls.gov> |
|---|---|
| First post | 2012-05-29 11:15 -0400 |
| Last post | 2012-05-29 23:02 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Tim Slattery <Slattery_T@bls.gov> |
|---|---|
| Date | 2012-05-29 11:15 -0400 |
| Subject | When is onclick *not* triggered? |
| Message-ID | <gep9s7pei50vqjmuoerjb96lbvf1huknt7@4ax.com> |
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>
The "submit_page" script sets a couple of values and submits the form
Works just fine, nearly always.
The problem is that in a very few cases, it looks like the href tag is
activated (for lack of a better term) without triggering the onclick.
The result is that the page is submitted to a nonexistent address.
So my question is how could this happen? I've tested tabbing to the
continue arrow, then using the enter key, CTRL-enter, and several
other combinations. All seem to work. Is there any way to activate the
"a" tag without triggering the onclick?
The errors seem to be reported by people using IE8. I've run my tests
with that browser and haven't turned up anything.
--
Tim Slattery
Slattery_T@bls.gov
[toc] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2012-05-29 17:40 +0200 |
| Message-ID | <2017556.lXCzD688iH@PointedEars.de> |
| In reply to | #14207 |
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>
[toc] | [prev] | [next] | [standalone]
| From | Richard Cornford <Richard@litotes.demon.co.uk> |
|---|---|
| Date | 2012-05-29 08:47 -0700 |
| Message-ID | <93414503-3489-40b9-a445-0dde3dabd71d@6g2000vbv.googlegroups.com> |
| In reply to | #14207 |
On May 29, 4:15 pm, 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: So an <input type="image"> could have given the save visual presentation. > <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> > > The "submit_page" script sets a couple of values and submits > the form > Works just fine, nearly always. Having a real submit button of some form and having onsubmit code add the values would be more reliable (and putting these values in the form to start with would be more reliable still). > The problem is that in a very few cases, it looks like the > href tag is activated (for lack of a better term) without > triggering the onclick. The result is that the page is > submitted to a nonexistent address. An empty HREF should be the top of the current page, which cannot be a non-existent page if you are already viewing it. > So my question is how could this happen? I've tested tabbing to the > continue arrow, then using the enter key, CTRL-enter, and several > other combinations. All seem to work. Is there any way to activate > the "a" tag without triggering the onclick? Right click and select "Open link", "Open in new tab" or "Open in new window" would bypass the onclick code (as you would not have 'clicked' in that case). Any error thrown in the - submit_page - function would prevent execution from getting to the - return false; - and so the default action of the A element would not be cancelled. There is also a possibly that a poorly coded add-on/toolbar or similar browser extension is interfering with the onclick code. Also, aggressive javascript code distributed with (some) adverts could be replacing onclick handlers (or interfering with them), but you wouldn't put an important form on a page that also imported content from uncontrolled sources so it won't be that. > The errors seem to be reported by people using IE8. I've run my tests > with that browser and haven't turned up anything. Richard.
[toc] | [prev] | [next] | [standalone]
| From | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| Date | 2012-05-29 23:02 +0200 |
| Message-ID | <4fc53966$0$6907$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #14207 |
"Tim Slattery" <Slattery_T@bls.gov> schreef in bericht news:gep9s7pei50vqjmuoerjb96lbvf1huknt7@4ax.com... > 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> > Can you leave the anchor element out; replace it with a <div onclick=...>. (Or maybe <img> itself can have the onclick.) Then there is no href and no race opportunity. If the onclick then fails, at least your debugging can be more focused. Tom
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web