由于最近的项目就是用WebView做的,所以最近对WebView的研究比较多一点。今天又发现一个WebView问题,查阅相关资料后认为这是WebView的一个bug,如果有人知道,能告诉原因就好了。
用WebView加载一个html页面,其中页面为了用户体验,加上了onmouseover,onmouseout等html语言,结果在手机上发现,这些个焦点的获取完全没有规律,比如我明明点在了上面,却发现下面某个按钮上有焦点了。这里坚定我认为是bug的原因是外国论坛上一个人提出的问题。以下是此人的问题:
来自 CSS
support on WebView
讨论的消息
X-BeenThere: android-developers@googlegroups.com
Received: by 10.90.41.34 with SMTP id o34ls530662ago.2.p; Mon, 15
Feb 2010
23:59:23 -0800 (PST)
Received: by 10.90.148.3 with SMTP id
v3mr3213592agd.3.1266307163130;
Mon, 15 Feb 2010 23:59:23 -0800 (PST)
Received: by 10.90.148.3 with SMTP id
v3mr3213590agd.3.1266307163096;
Mon, 15 Feb 2010 23:59:23 -0800 (PST)
Return-Path:
Received: from mail-yw0-f163.google.com (mail-yw0-f163.google.com
[209.85.211.163])
by gmr-mx.google.com with ESMTP id
25si775555ywh.8.2010.02.15.23.59.23;
Mon, 15 Feb 2010 23:59:23 -0800 (PST)
Received-SPF: pass (google.com: domain of mailfaridak...@gmail.com
designates 209.85.211.163 as permitted sender)
client-ip=209.85.211.163;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com:
domain of mailfaridak...@gmail.com designates 209.85.211.163 as
permitted sender) smtp.mail=mailfaridak...@gmail.com
Received: by ywh35 with SMTP id 35so16949744ywh.6
for
;
Mon, 15 Feb 2010 23:59:23 -0800 (PST)
MIME-Version: 1.0
Received: by 10.101.176.36 with SMTP id
d36mr358943anp.20.1266307162581; Mon,
15 Feb 2010 23:59:22 -0800 (PST)
Date: Mon, 15 Feb 2010 23:59:21 -0800 (PST)
X-IP: 124.30.49.130
User-Agent: G2/1.0
X-HTTP-Via: 1.1 Firewall-BOM1-1.synapse.com:3128
(squid/2.6.STABLE6)
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT
5.1; GTB6.4;
.NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET
CLR
3.5.30729),gzip(gfe),gzip(gfe)
Message-ID:
<5241f520-0a47-4445-87be-28d131ebe18f@v20g2000prb.googlegroups.com>
Subject: CSS support on WebView
From: farida
To: Android Developers
Content-Type: text/plain; charset=ISO-8859-1
Hello All,
I have a requirement of using a WebView to
display the jsp pages from
the server which uses JSTL. Here we have buttons in tabular
form
displayed using
first button needs to shown as
selected with the CSS enabled for that selection. The buttons here
are
simple input type button with in an anchor tag to navigate to
other
pages
οnmοuseοut="focusOnMouseOut('abc_0','btn');"
id="abc_${status.index}"
class="btn"
href="abcd.jsp?cid=${abc.id}">
type="button"
name="abButton_${status.index}" value="${name}" title="$
{fn:escapeXml(abc.name)}"
class="flex-btn">
but the problem is that on device the default focus is not always
on
the first button and after that the trackball scrolling is also
not
definite. It sometimes scrolls properly and sometimes does not
scroll
at all through all the elements in the page. We need the focus on
the
first button always when ever we navigate to the page either
first
time or through the back key. At present we are calling a
javascript
function on onLoad of the
toset the focus on the first button
and then update the CSS class also to show it as focussed and
selected.
We have lots of CSS applied on the page to get the rich look of
the
Android client on these pages.
Please let me know if there is some solution for this. Is it
the
problem of CSS being applied or WebView is
not able to support the CSS?
这个问题我没有回答他,因为我不知道这是什么原因,但我自己用其他方法解决了。当然,我的方法也比较搓,他不行我就换其他的。为了达到同样的用户体验,选择苹果的那一套,即ontouchstart,ontouchend因为Android的WebView是基于webkit的,与苹果的safari是同一内核,这样既解决了焦点获取问题,也达到了同样的用户体验。
如果有人知道用onMouseover为什么不行的话,请留言。谢谢。