从Android 4.4.x WebView中使用location.reload当打开一个标签在浏览器()浏览器、标签、Android、WebView

2023-09-06 14:46:49 作者:墨香染城

所有这些在浏览器中打开一个新的标签与我的应用程序的URL,

All these open a new tab with my app url, in the browser:

location.reload()
document.location.reload()
window.location.reload()
window.location.href = window.location.pathname
window.location.search = ''

这是因为Android 4.4的新的行为。

It's new behavior since Android 4.4.

我真的preFER到一个新的Andr​​oid包不上传到店,简单地修复location.reload()。整个原因,我重装是刷新我的应用程序缓存我刚刚更新。这是正常的,并鼓励移动网络的工作流程。

I'd really prefer to not upload a new Android package to the store, to simply fix location.reload(). The whole reason I'm reloading is to refresh my appcache I just updated. Which is a normal and encouraged mobile web workflow.

我希望有出有什么我还没有从JavaScript尝试,将工作。

I'm hoping there is something out there I haven't tried from javascript that will work.

推荐答案

您是否尝试过使用类似的WebClient的这个

Have you tried using a webClient like this one

private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

}