Currently, I am utilizing JavaScript to recognize taps within a page displayed in a UIWebView. Here is an example of my code:
<div id="wrapper">
<a href="http://apple.com">Apple</a>
</div>
<script>
document.getElementById("wrapper").addEventListener('click', function() {
document.location = 'internal://tap';
}, false);
</script>
My approach involves intercepting links using the web view delegate and searching for "internal://tap". Once found, I prevent navigation within the web view and handle the tap accordingly. However, this method causes the loss of text selection capability. Despite this issue, tapping the link itself continues to function as expected.
Interestingly, simply adding an event listener for 'click' results in the inability to select text, even if the handler does not manipulate the document location.
Do you have any insights on what mistakes I might be making?