I am trying to get the custom back button in Javascript on the webpage to work when the webpage is opened in the android webview.
The phone's standard back button on the bottom of the screen works fine. (the device's back button).
But how do I get the custom back buttom on the screen to work in the same way ?
I tried on the Javascript side; (mysettings.php)
<a href="#" onclick="history.back()"><img class="bla" src="images/bla.jpg"></a>
<a href="#" onclick="history.back();return false"><img class="bla" src="images/bla.jpg"></a>
<a href="javascript: window.history.go(-1)"><img class="bla" src="images/bla.jpg"></a>
A hyperlink works, but reloads the main page which I don't want. I just want to reshow the main page.
I could write some Java code here that I tried, but it doesn't seem to relate to the problem. E.g.
On the JAVA side (MainActivity.java)
@Override
public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}
Does anyone have experience with a custom javascript back button for an app webview ?