在Android浏览器链接并不总是执行的onClick造成焦点,而不是并不、而不是、浏览器、链接

2023-09-05 03:54:57 作者:朝阳少年我的心

我想程序使用HREF链接一个非常标准的JS行为 onclick处理程序,而我面对由什么原因引起我认为是在Android对焦/触摸模式行为,一个奇怪的问题。

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?).

伪code现在的问题是

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.

推荐答案

尝试在web视图中启用JavaScript。

Try enabling Javascript on the webview.

在保存web视图的活动,试试这个......

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

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

我有他同样的问题,但想通了,那是因为我没有启用JavaScript。

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