在 Android 浏览器中,链接并不总是执行 onClick 导致焦点 [英] In Android Browser link does not always execute onClick causing focus instead

查看:38
本文介绍了在 Android 浏览器中,链接并不总是执行 onClick 导致焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为使用 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?).

现在的伪代码是

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

我试过做类似的事情:

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

但有时我仍然会遇到同样令人讨厌的问题.

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

推荐答案

尝试在 webview 上启用 Javascript.

Try enabling Javascript on the webview.

在拥有 webview 的 Activity 中,试试这个...

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.

这篇关于在 Android 浏览器中,链接并不总是执行 onClick 导致焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆