Android 4.4.x WebView opens a tab in the browser when using location.reload()

*爱你&永不变心* 提交于 2019-12-08 08:16:44

问题


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 = ''

It's new behavior since Android 4.4.

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.

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


回答1:


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;
}

}



来源:https://stackoverflow.com/questions/20510071/android-4-4-x-webview-opens-a-tab-in-the-browser-when-using-location-reload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!