WebView利用copyBackForwardList返回主页

1
2
int size = webview.copyBackForwardList().getSize();
webview.goBackOrForward(size - 2*size);

WebBackForwardList copyBackForwardList():存放webview的历史记录, getsize() -> 历史记录个数

goBackOrForward:

1
2
3
4
public void goBackOrForward (int steps)

Go to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
Parameters steps The number of steps to take back or forward in the back forward list.