开发者

WebView.onPageFinished (WebView, String)

开发者 https://www.devze.com 2023-03-15 09:16 出处:网络
I am trying to figure out what is the best way to load url in Android\'s WebView, and also need to be able to change its fragmentId. The problem is that the following code does not work:

I am trying to figure out what is the best way to load url in Android's WebView, and also need to be able to change its fragmentId. The problem is that the following code does not work:

        web0.loadUrl("file:///android_asset/fragmentchange.html");
        web0.loadUrl("javascript:window.location.hash='#newframent'");

I believe it is because that the second line is executed before the page finished loading. So, the fragment is never set. Or it is somehow got overwritten. Anyways, I have to using the following call back to make sure the WebVi开发者_开发知识库ew finished loading, then change the fragment.

           // Override this call
            WebViewClient.onPageFinished();
           // to mark WebView finished the page load.

          //  In a separate thread, 
               if(web0.pageloadFinished()) {
                web0.loadUrl("javascript:window.location.hash='#newframent'");
               }

Now, I am trying to understand when the WebViewClient.onPageFinished() is called, and if there is still possibility that the fragmentId get lost.


web0.loadUrl("javascript:window.location.hash='#newframent'");
0

精彩评论

暂无评论...
验证码 换一张
取 消