问题
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