开发者

Soft back button in Android using Webview

I'm writing an Android program using Webview that can use the hard back key on the device, no problem with this.

But when the program goes "outside" and navigates through HTML / Javascript pages inside the Webview "wrapper" it cannot handle开发者_如何学Go properly an href="javascript:window.history.back();" button, because it does not go up one level, just goes back and forward the previous page.

What am I doing wrong?


The javascript.window.history.back() function is designed to move back one step in the browser history. It does not (even on android platforms) emulate a click of the device's back button.

I believe the WebView component intercepts a press of the device's back button to allow a user to navigate back though the history until the point that the WebView was created (i.e. the first page viewed).

These two functions are completely separate, defined in different languages and one cannot be used for the other. If you want to implement the functionality of the device's back button you will need to do this within the application code, not a web page (a call to onKeyPress() should do the trick).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜