<i id='cnvWs'><tr id='cnvWs'><dt id='cnvWs'><q id='cnvWs'><span id='cnvWs'><b id='cnvWs'><form id='cnvWs'><ins id='cnvWs'></ins><ul id='cnvWs'></ul><sub id='cnvWs'></sub></form><legend id='cnvWs'></legend><bdo id='cnvWs'><pre id='cnvWs'><center id='cnvWs'></center></pre></bdo></b><th id='cnvWs'></th></span></q></dt></tr></i><div id='cnvWs'><tfoot id='cnvWs'></tfoot><dl id='cnvWs'><fieldset id='cnvWs'></fieldset></dl></div>

      <bdo id='cnvWs'></bdo><ul id='cnvWs'></ul>
    <tfoot id='cnvWs'></tfoot>

    1. <legend id='cnvWs'><style id='cnvWs'><dir id='cnvWs'><q id='cnvWs'></q></dir></style></legend>

        <small id='cnvWs'></small><noframes id='cnvWs'>

        E/Web 控制台(8272):未捕获的 ReferenceError:未定义函数名称:1 在视图寻呼机中加载 web

        时间:2023-10-03
          <bdo id='X2clV'></bdo><ul id='X2clV'></ul>

        • <legend id='X2clV'><style id='X2clV'><dir id='X2clV'><q id='X2clV'></q></dir></style></legend>
          <tfoot id='X2clV'></tfoot>
            <tbody id='X2clV'></tbody>
          <i id='X2clV'><tr id='X2clV'><dt id='X2clV'><q id='X2clV'><span id='X2clV'><b id='X2clV'><form id='X2clV'><ins id='X2clV'></ins><ul id='X2clV'></ul><sub id='X2clV'></sub></form><legend id='X2clV'></legend><bdo id='X2clV'><pre id='X2clV'><center id='X2clV'></center></pre></bdo></b><th id='X2clV'></th></span></q></dt></tr></i><div id='X2clV'><tfoot id='X2clV'></tfoot><dl id='X2clV'><fieldset id='X2clV'></fieldset></dl></div>

                1. <small id='X2clV'></small><noframes id='X2clV'>

                  本文介绍了E/Web 控制台(8272):未捕获的 ReferenceError:未定义函数名称:1 在视图寻呼机中加载 web 视图时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在视图寻呼机中加载网络视图.

                  I am trying to load webviews in a view pager.

                  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                           Bundle savedInstanceState) {
                      View v = null;      
                      v = inflater.inflate(R.layout.webview_layout, container, false);
                      myWebView = (WebView)v.findViewById(R.id.webview1);
                      WebSettings webSettings = myWebView.getSettings();      
                      webSettings.setJavaScriptEnabled(true);
                      webSettings.setAppCacheEnabled(true);
                      webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
                      myWebView.loadUrl("file:///android_asset/web/index.html");
                      myWebView.setWebViewClient(new WebViewClient() {
                          @Override
                          public void onPageFinished(WebView view, String url) {
                              myWebView.loadUrl("javascript:testFunction()");
                          }
                      }
                  }
                  

                  加载页面后,在onPageFinished()中调用了一个javascript函数以正常速度滚动时,网页正在加载并执行 javascript.

                  After loading the page, a javascript function is called in onPageFinished() While scrolling at normal speed the webpages are loading and the javascript is executed.

                  但是在高速滚动时出现以下异常.

                  But while scrolling at high speed the following exception is occured.

                  > 09-06 14:29:06.750: E/Web Console(8272): Uncaught ReferenceError:
                  > testFunction is not defined:1
                  

                  testFunction() 是

                  testFunction() is

                  function testFunction(){
                      console.log("TestFuntion");     
                  }
                  

                  请帮忙...

                  推荐答案

                  我已经解决了这个问题

                  只需设置 webChromeClient 并捕获错误并重新加载页面...

                  just set webChromeClient and catch the error and reload the page...

                      myWebView.setWebViewClient(new WebViewClient() {
                          @Override
                          public void onPageStarted(WebView view, String url, Bitmap favicon) {
                              isLoading = true;
                          }
                  
                          @Override
                          public void onPageFinished(WebView view, String url) {
                              myWebView.loadUrl("javascript:testFunction()");
                          }
                      });
                  
                      myWebView.setWebChromeClient(new WebChromeClient() {
                          @Override
                          public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                              MessageLevel level = consoleMessage.messageLevel();
                              if(level.ordinal() == 3) { // Error ordinal
                                  if(loading) {
                                      myWebView.stopLoading();
                                      myWebView.loadUrl(AppConstants.ARTICLE_PAGE_URL);
                                  }
                              }
                          }
                          return false;
                      }
                  

                  这篇关于E/Web 控制台(8272):未捕获的 ReferenceError:未定义函数名称:1 在视图寻呼机中加载 web 视图时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:点击 Viewpager Xamarin Android 下一篇:单个 ListView 内的多个 ViewPagers 崩溃

                  相关文章

                    <legend id='g1JGB'><style id='g1JGB'><dir id='g1JGB'><q id='g1JGB'></q></dir></style></legend>
                  1. <i id='g1JGB'><tr id='g1JGB'><dt id='g1JGB'><q id='g1JGB'><span id='g1JGB'><b id='g1JGB'><form id='g1JGB'><ins id='g1JGB'></ins><ul id='g1JGB'></ul><sub id='g1JGB'></sub></form><legend id='g1JGB'></legend><bdo id='g1JGB'><pre id='g1JGB'><center id='g1JGB'></center></pre></bdo></b><th id='g1JGB'></th></span></q></dt></tr></i><div id='g1JGB'><tfoot id='g1JGB'></tfoot><dl id='g1JGB'><fieldset id='g1JGB'></fieldset></dl></div>

                        <bdo id='g1JGB'></bdo><ul id='g1JGB'></ul>
                    1. <small id='g1JGB'></small><noframes id='g1JGB'>

                      <tfoot id='g1JGB'></tfoot>