In Android Browser link does not always execute onClick causing focus instead

10,696

Try enabling Javascript on the webview.

In the activity that holds the webview, try this...

WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setJavaScriptEnabled(true);

I was having he same problem, but figured out it was because I did not enabled Javascript.

Share:
10,696
Artem
Author by

Artem

Updated on June 05, 2022

Comments

  • Artem
    Artem almost 2 years

    I am trying to program a very standard JS behavior for a link using an HREF onClick handler, and I am facing a strange problem caused by what I believe to be focus/touch mode behavior on Android.

    Sometimes when I click on the link, instead of executing the action, it simply becomes selected/focused, with either just a focus rectangle or even also with a filled focus rectangle (selected as opposed to just focused?).

    The pseudo-code right now is

    <a href="#" onClick="toggleDivBelowToShowHide(); return false;">go</a>
    

    I have tried doing something like:

    <a href="#" onTouchStart="toggleDivBelowToShowHide(); return false;">go</a>
    

    But I still get the same pesky problem some of the time.