0

This is a part of code, I click a link like <a href="www.abc/file.php?download&sn=6"></a> , it should go if() but it always run the else() one, help me to check the code thx :)

public class WebClient : WebViewClient
    {

        public override bool ShouldOverrideUrlLoading(WebView view, string url)
        {

            if (url.Contains("download"))
            {
                var url2 = "https://www.google.com.tw/";
                view.LoadUrl(url2);

            }
            else
            {
                //return base.ShouldOverrideUrlLoading(view, url);
                view.LoadUrl(url);

            }
            return true;
        }

my complete code is here except the webviewclient part,it's different in this case.

Community
  • 1
  • 1
Y2H
  • 33
  • 1
  • 8
  • You can check the spelling name of "download" text in url and after that debug your code. – A-Droid Tech Apr 18 '17 at 10:09
  • @Y2H The link you have in the description is not working, did you try a link that works? – Johny Apr 18 '17 at 10:15
  • I'm not sure about your meaning, but "download" is not a variable in url,it's static string. – Y2H Apr 18 '17 at 10:19
  • To Johny:that is fake one , here is real one :http://www.recc.com.tw/recc_app/ch/lecturer_curriculum_edit.php?a=Modify&s=151&opp=download&kind=curriculum_file&ds=132 – Y2H Apr 18 '17 at 10:24
  • I tried with certain real url, but didn't reproduced the problem. Could you please debug to check: 1. Whether `ShouldOverrideUrlLoading` function get called. 2. Whether the value of `url` argument contains substring `download`. – Elvis Xia - MSFT Apr 19 '17 at 06:21
  • To Elvis: May i ask how to check url value that webview load? – Y2H Apr 19 '17 at 09:29

0 Answers0