Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7945
| Date | 2011-11-03 18:02 +1100 |
|---|---|
| From | Andrew Poulos <ap_prog@hotmail.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: ontouch onclick and ios |
| References | <c86dneOQb4QFvy_TnZ2dnUVZ_j-dnZ2d@westnet.com.au> |
| Message-ID | <HuOdnRCEreQ7oS_TnZ2dnUVZ_o6dnZ2d@westnet.com.au> (permalink) |
On 3/11/2011 4:11 PM, Andrew Poulos wrote:
> I have this in a page
>
> function touchStart(event) {
> event.preventDefault();
>
> // more code here...
> }
>
> window.ontouchstart = touchStart;
>
> What I don't understand is:
> - why the preventDefault on line 2 also kills the onclick event on iOS
To answer my own question it seems that preventing the default on a
touch start event consumes (if that's the right term) the onclick event
as well.
> - why preventDefault is needed
And prevent default stops swipes dragging the page about.
---
One new question though. If the current code uses onclick is there a way
to have them all replaced/changed with ontouchstart without having to
manually go through and edit the code?
So , for example,
elem.onclick = a;
would become
elem.ontouchstart = a;
Andrew Poulos
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ontouch onclick and ios Andrew Poulos <ap_prog@hotmail.com> - 2011-11-03 16:11 +1100
Re: ontouch onclick and ios Andrew Poulos <ap_prog@hotmail.com> - 2011-11-03 18:02 +1100
Re: ontouch onclick and ios Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2011-11-03 18:15 +1100
Re: ontouch onclick and ios Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2011-11-03 18:05 +1100
Re: ontouch onclick and ios David Mark <dmark.cinsoft@gmail.com> - 2011-11-03 07:37 -0700
csiph-web