Search code examples
javascriptiosios6dom-events

onClick event issue on iOS6


In my HTML page I have an onClick event which navigates to next page. When this is opened in UIWebView for iOS 5 it works perfectly, but this is not working in iOS 6. I am unable to navigate to another page.

I thought iOS 6 doesn't support onClick events, we have to support onClick event, as we need get this work on both iOS6 and iOS5. I have created a small JS function, which I feel this could fix my issue.

<img src="resources/images/arrowRight.png" id = "rightArrow" class="arrowNavRight"/>
<script>
    document.getElementById("rightArrow").onclick=function(){nextSlide()};
</script>

The above is what I have done to resolve the issue. It is working fine in Chrome but not in the app. I am very new in using Javascript. Has anyone else faced this issue?. Your help is highly appreciated.


Solution

  • If you are developing for mobile, you should use 'touchstart' rather than 'onclick'.

    Also, if you are using Phonegap, I would suggest using Jquery and Jquery mobile.