android - WebView加载天猫等购物网页出问题?
巴扎黑
巴扎黑 2017-04-17 18:00:58
0
4
719

用WebView加载淘宝等一些购物网站时,可以链接到首页,但从首页再点击进入详情页就无法加载,该怎么解决?

巴扎黑
巴扎黑

reply all(4)
巴扎黑

Thank you for your answers. It has been solved now, but I still don’t understand the principle. I hope someone can explain the reason.
This method was set up before, but the display is outdated and some shopping websites such as Taobao and Tmall cannot be loaded correctly:

webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });

It will be ok if I switch to another method of overloading later, but I still hope someone can explain why?

@Override
        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
            view.loadUrl(request.toString());
            return true;
        }

You can also directly copy the following method

 @Override
       public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
           handler.proceed();
       }

I found an article explaining WebView in detail

PHPzhong

It should be that webview cannot recognize tmall at the beginning of the URL. You can try replacing it with https every time webview loads

Peter_Zhu

This tamll is used to wake up the Tmall APP on the mobile phone. Because the default webview does not support waking up any app, an error will occur.

If you want to open Tmall or Taobao on the current page
, you need to re-parse its link. You can see that the url of the actual product is "url?=" after the question mark. You can parse the value of the url and open it by calling webview. This is modified in the same place as wake-up, both in shouldOverrideUrlLoading. The loaded url here determines whether it starts with tmall. If it does, parse it. If not, determine whether it starts with http or https, and then load it

You can read this article. I have done a wake-up call but can’t find the code.

http://www.jianshu.com/p/fd04...

Ty80

tmall:// This is the jump schema protocol dedicated to Tmall app. You definitely cannot open it in webview.

If you have the Tmall app client installed on your phone, you can automatically wake up the app to open the page

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template