views:

402

answers:

1

As usual, I'm trying to do something the easiest way possible, in this case implement a double-tap handler on a UIWebView like so:

<div id="foo" ondblclick="clickHandler(this);" ... >

It works fine in Safari and Firefox, and I know the code containing clickHandler is loading on the iPhone thanks to a now-annoying alert stmt at the end of loading.

If I change ondblclick to onclick it works on both the device and the simulator.

From reading similar queries it would seem that I need to intercept the taps in ... and then run my JavaScript code with the stringByEvaluatingJavaScriptFromString method, but then how do I know the JS id of the target? I no like that, would rather write a pure HTML/DOM/JS solution. Or since my app is about 80% web content, should I be using phonegap instead?

A: 

MobileSafari doesn't support the double click event. Besides, double tapping on MobileSafari already has a well-defined operation — zooming.

You can install an onClick handler, and detect the time intervals between 2 clicks to determine whether it's a double click or not.

KennyTM