1
如何在android浏览器中捕捉浏览器关闭或更具体的页面卸载事件?我不能让它在Android浏览器http://developer.android.com/reference/android/webkit/WebChromeClient.html在Android浏览器中捕捉浏览器关闭事件
工作与活动,如unload
,beforeunload
等
如何在android浏览器中捕捉浏览器关闭或更具体的页面卸载事件?我不能让它在Android浏览器http://developer.android.com/reference/android/webkit/WebChromeClient.html在Android浏览器中捕捉浏览器关闭事件
工作与活动,如unload
,beforeunload
等
/* Tell the client to display a dialog to confirm navigation away from
the current page. This is the result of the onbeforeunload javascript event.
If the client returns true, WebView will assume that the client will handle
the confirm dialog and call the appropriate JsResult method. If the client
returns false, a default value of true will be returned to javascript to accept
navigation away from the current page. The default behavior is to return false.
Setting the JsResult to true will navigate away from the current page, false will
cancel the navigation.
*/
public boolean onJsBeforeUnload (WebView view, String url, String message, JsResult result){
}
我想你可能也将代码注入通过网页视图显示在您的网页:
<script type="text/javascript">
function OnBeforeUnLoad() {
return "";
}
</script>
使用
@Override
public void onPageFinished(WebView view, String url)
{
webview.loadUrl("string with your script");
}
你说话通过使用Java编程或从移动网络来处理这个问题? –
WebViewClient可能对您有所帮助:http://developer.android.com/reference/android/webkit/WebViewClient.html –
即时通讯讨论如何在JavaScript中处理此事件。 – Hari