안드로이드 webview에서 팝업창 및 팝업창 닫기
페이지 정보
작성일 23-03-09 14:33
본문
private class mWebChromeClient extends WebChromeClient { @Override public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, android.os.Message resultMsg) { view.removeAllViews(); WebView childView = new WebView(view.getContext()); childView.getSettings().setJavaScriptEnabled(true); childView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); childView.getSettings().setSupportMultipleWindows(true); childView.setWebChromeClient(this); childView.setWebViewClient(new WebViewClient() { //@Override public void onCloseWindow(WebView window) { window.destroy(); } }); childView.setLayoutParams( new LinearLayout.LayoutParams(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT) ); view.addView(childView); WebView.WebViewTransport transport = (WebView.WebViewTransport)resultMsg.obj; transport.setWebView(childView); resultMsg.sendToTarget(); return true; } @Override public void onCloseWindow(WebView window) { Log.i(getClass().getName(), "onCloseWindow"); window.setVisibility(View.GONE); window.destroy(); //mWebViewSub=null; super.onCloseWindow(window); } @Override public boolean onJsAlert(WebView view, String overrideUrl, String message, final JsResult result) { new AlertDialog.Builder(view.getContext()) .setTitle("Alert") .setMessage(message) .setPositiveButton(android.R.string.ok, new AlertDialog.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { result.confirm(); } }) .setCancelable(false) .create() .show(); return true; }
웹에서 window.open 호출시 opt항목을 없애주는게 편함
var opt = 'left=100,top=100,width=600,height=600,scrollbars=1'; if(g5_cma_is_hybrid) { opt = ''; } var win_board_singo_win = window.open(url, 'cma_win_board_singo', opt); win_board_singo_win.focus(); if(g5_cma_is_hybrid) { $("html, body").animate({scrollTop:0}, '500'); }
추천
0
비추천
0
- 이전글 font Awesome icons 검색페이지 23.03.28
- 다음글 get_paging 페이징함수 1페이지 일때 page변수 사용하지 않게 변경 23.03.06
총모아 님의 댓글
총모아 작성일좋아요