javascript界面​​在5.0以下不起作用

时间:2015-06-04 06:45:47

标签: javascript android

  1. 当我的webview扩展时,我使用下面的代码来避免空格 它在5.0
  2. 中运行良好

    我添加了suppresslint @SuppressLint({" SetJavaScriptEnabled"," JavascriptInterface"})以避免错误

    但Android 4.2,4.3设备仍有空白区域

    有人建议我解决这个问题。

    web_content_url.setWebViewClient(new WebViewClient() {
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {
                        Log.i(TAG, "Processing webview url click...");
                        pbar2.setVisibility(view.VISIBLE);
                        view.loadUrl(s[1]);
                        return true;
                    }
    
                    public void onPageFinished(WebView view, String url) {
                        Log.i(TAG, "Finished loading URL: " + url);
                        pbar2.setVisibility(view.GONE);
                        view.loadUrl("javascript:MyApp.resize(document.body.getBoundingClientRect().height)");
                        super.onPageFinished(view, url);
    
                    }
    
                    public void onReceivedError(WebView view, int errorCode,
                            String description, String failingUrl) {
                        Log.e(TAG, "Error: " + description);
                        pbar2.setVisibility(view.VISIBLE);
                    }
    
                });
                web_content_url.addJavascriptInterface(this, "MyApp");
    

0 个答案:

没有答案