简体   繁体   中英

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

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.

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM