<a> tag onclick event not firing reliably when tapped on iPod Touch Safari

Ast35 used Ask the Experts™
We are building a mobile website using JQTouch, and we need to trigger a Javascript function when a link is tapped, but the onclick event seems to be firing only some of the time. I think it has to do with the amount of pressure used for the tap. The link itself is being followed all the time, but the function only executes some of the time. Which isn't much good as the div the link goes to is supposed to display information output by the function.

Any ideas?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can I see how you have your link set up?


<a id="getresultsbutton" class="flipleft getresults" href="#results"  onclick="getInitialresults(); " >Get results</a>

It works as expected when I click it in Firefox.
You might want to consider disabling the href with something like "javascript:void(0);" and placing a window.location = "http://yoursite.com/"; in your getInitialresults() function.
Top Expert 2014

Try to use a DIV instead a link
I tried those, and the result was that getInitialresults() was executing, but the site was not transferring to the correct screen (despite the correct URL displaying in the address bar).

But I've got it working.

I found a 'tap' event specific to the JQTouch plugin. I removed onclick="getInitialresults(); " and added the following -

                $('#getestimatesbutton').bind('tap', function () {

It is odd that the onclick event was only working some of the time though.

Thanks for trying to help!


Accepting my own post as the solution so that I can close the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial