1

I want to open link with target='_blank' in new tab. In webview how i can detect anchor tag target value. Now when i click on any link in webview it open in same tab. I just want to detect target value.

It's simple i just want to know target of anchor tag in webview.

My code for webview.

    public class WebViewClient extends android.webkit.WebViewClient
    {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {    
            // TODO Auto-generated method stub

            super.onPageStarted(view, url, favicon);    
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            // TODO Auto-generated method stub
            view.loadUrl(url);
            EditText editText = (EditText) findViewById(android.R.id.edit);
            editText.setText(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {

            // TODO Auto-generated method stub

            super.onPageFinished(view, url);

        }
    }

 WebView web1;
                //EditText editText = findViewById(android.R.id.edit);

                //String Address = "https://www.google.com/search?q=" + editText.getText().toString();
                web1 = (WebView) findViewById(R.id.webview);
                String webUrl = web1.getUrl();
                Log.d("type", "tab web: " + webUrl);
                editText.setText(webUrl);
                WebSettings webSetting = web1.getSettings();
                webSetting.setBuiltInZoomControls(true);
                webSetting.setJavaScriptEnabled(true);
                web1.setWebViewClient(new WebViewClient());
                web1.loadUrl(webUrl);
aman
  • 33
  • 10
  • Possible duplicate of [Android - Open target \_blank links in WebView with external browser](https://stackoverflow.com/questions/18187714/android-open-target-blank-links-in-webview-with-external-browser) – Lal Sep 26 '17 at 16:56
  • It's different. i want to know the target. – aman Sep 26 '17 at 17:49
  • I don't really understand what you want? What do you want do you want to open a new page get to know what page your are opening? – Steven Sep 28 '17 at 14:17
  • I am facing the same issue. Let me know if you found any solution or else i will go to javascript interface. – venu46 Nov 11 '21 at 12:50

0 Answers0