Chris Chris - 7 months ago 106
Android Question

WebView does not reload anymore on document.location change

I have a plain html / javascript App (no Phonegap) that i use with a native Android App and a WebView.

In the JavaScript part i have to reload the current page in some situations. With my old Phone and Android 4.3 i just used:

document.location = "index.html"

with my new Phone (Android 5) this seems not to work anymore. It stil works to change the page i.E. when i am currently viewing "books.html" i can use the above code to navigate to "index.html". But when i want to reload the same page i am currently viewing, nothing happens.

I debugged the WebView with the chrome debugger, no errors, no warnings, nothing. In chrome on my pc everything works fine.

Please Note:

I tried the solution mentioned by Rajesh. Unfortunately it didn't work out of the box.

I came across this issue:

Its necessary to set a WebViewClient on the webView to make it work:

webView.setWebViewClient(new WebViewClient());


document.location method will not reload page it essentially make entry to session history and make separate visit to page.

it may be possible that some browser implementation restrict adding side by side duplicate entry to session history, thus preventing reload of page.

best method to reload page is document.location.reload()