This problem occurs in the stock browser included with at least Android 4.1.2 (not Mobile Chrome) and the WebView component in a cordova-based android app we're building.
I've built a page with a fixed header at the top of the view that contains a horizontally scrollable set of tabs with the basic DOM and inline CSS below, and click handlers attached to each of the tabs are not firing.
<html>
...
<body>
<div>
<header class="navheader" style="position: fixed; z-index: 1000;">
<h1>....</h1>
<nav style="width: 100%; overflow: scroll; -webkit-overflow-scrolling: touch;">
<div class="tabs">
<div class="tab"><a target='_blank' href="...">...</a></div>
<div class="tab"><a target='_blank' href="...">...</a></div>
<div class="tab"><a target='_blank' href="...">...</a></div>
<div class="tab"><a target='_blank' href="...">...</a></div>
<div class="tab"><a target='_blank' href="...">...</a></div>
<div class="tab"><a target='_blank' href="...">...</a></div>
...
</div>
</nav>
</header>
<section>
...
</section>
</div>
</body>
</html>
I've tried attaching a click handler in several ways with jQuery, such as:
$('body').on('click', 'header .tab', function(event){ ... });
or
$('.tabs .tab').on('click', function(event){ ... });
along with variations on the selector like 'header .tabs a', 'header .tabs .tab a', and 'header a'. I also tried:
$('.tabs .tab a').each(function(i) { this.onclick=function(){ ... }; });
and adding the onclick attribute to each a
tag:
<div class="tab"><a target='_blank' href="..." onclick="alert('hi');">...</a></div>
None these worked.
Using this code, though:
$('body').on('click', function(event){
console.log("Click" + $(event.target).attr('class'));
});
The click event will print 'navheader' or whatever is behind the element with 'overflow: scroll' set. Adjusting the z-index for each tab, the tabs container, and/or the nav elem had no effect on this either.
Removing 'overflow: scroll' from the CSS alleviates the problem and the events fire with any of the methods for registering a handler (the '-webkit-overflow-scrolling: touch' seemed to have no effect). But then I obviously lose the ability to scroll horizontally. Thus, it seems like elements with scrollable inner content are in some way removed from the event bubbling hierarchy. It also works in Mobile Chrome and all things iOS.
Has anyone found a work-around?
Also, webView.getSettings().setJavaScriptEnabled(true);
is declared in for WebView.
I can't quite seem to get the SearchField to work in extJS. I want to implement it in the table toolbar, and perform the filter on my table store object. I have my require setup like this : Ext....
I can't quite seem to get the SearchField to work in extJS. I want to implement it in the table toolbar, and perform the filter on my table store object. I have my require setup like this : Ext....
I'm trying to replace the standard javascript confirm with a twitter bootstrap modal window. Everything is almost working (the modal is shown with its confirm text), but I'm stuck trying to catch the ...
I'm trying to replace the standard javascript confirm with a twitter bootstrap modal window. Everything is almost working (the modal is shown with its confirm text), but I'm stuck trying to catch the ...
I'm trying to intercept web requests and redirect them to a url I have saved on local storage but it isn't working. My code is as follows: chrome.webRequest.onBeforeRequest.addListener( function ...
I'm trying to intercept web requests and redirect them to a url I have saved on local storage but it isn't working. My code is as follows: chrome.webRequest.onBeforeRequest.addListener( function ...
I want to display a hidden field when I make a particular selection using the radio button. Currently I have wriiten the code with onClick. But somehow it doesnt seem to be working for me. <td ...
I want to display a hidden field when I make a particular selection using the radio button. Currently I have wriiten the code with onClick. But somehow it doesnt seem to be working for me. <td ...