链接有时不工作的WebView链接、工作、WebView

2023-09-04 23:34:34 作者:谁来倾听、那份忧伤

在在的WebView际链接不会响应。亮点preSS的颜色会出现在他们周围,但没有任何反应。我也使用WebViewClient的shouldOverrideUrlLoading而发生这种情况时该函数没有被调用。

On occasion links in the WebView will not respond. The highlight press color will appear around them but nothing happens. I am also using WebViewClient's shouldOverrideUrlLoading and that function is not called when this happens.

编辑:

我已经缩小这个问题到下列情形之一的:

I have narrowed this issue down to the following circumstances:

在该网页的第一页的WebView打开。 在该网页使用META NAME =视属性在HTML头 web视图使用WebView.getSettings()setUseWideViewPort(真); 的Andr​​oid 2.1(不出现的情况发生在以后的版本中,前面没有测试)

如果一个网页的会议上面打开任何链接将正常工作。如果加载另一个类似的网页,这些链接将不能工作。它不是,直到你加载网页没有META NAME =视口的链接开始工作。之后没有了元属性页面打开,然后你用元视属性加载一个网页,链接开始工作。

If a webpage meeting those above is opened no links will work. If another similar page is loaded, those links will not work either. It is not until you load a page without meta name="viewport" that links start to work. After a page without that meta attribute is opened and then you load a page with the meta viewport attribute, the links start working.

推荐答案

这似乎是一个可笑的变通方法,但我想它的工作原理。第一次的WebView加载,如果加载像

This seems like a ridiculous work around but I guess it works. The first time the WebView loads, if you load a blank dummy html file like

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>

在你加载其它任何东西,这似乎解决这​​个问题。它也像假文件已完全加载第一,不只是开始加载。

before you load anything else, it appears to fix the problem. It also looks like the dummy file has to load completely first, not just start loading.