prowebview icon indicating copy to clipboard operation
prowebview copied to clipboard

ProWebview doesn't open inner URL with the html Tag traget_blank

Open korchix opened this issue 6 years ago • 4 comments

hey thank you for this nice library, i have just one Problem with the ProWebview.

when i load for example this url https://coinmarketcap.com/currencies/bitcoin/ in the ProWebview and try to click on an inner url that normally will be opened in a new browser tab, the ProWebview did nothing, as if it ignore the click completely. how can it tell the webview, that it should open this Link as in the same view ?

can you please help with that. i'm using a fragment within an activity to show the webview: here is my webview xml.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <vcm.github.webkit.proview.ProWebView
        android:id="@+id/webview_search"
        app:cacheMode="cacheElseNetwork"
        app:javascriptEnabled="true"
        app:nestedScrollingEnabled="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</FrameLayout>

an the webview implementation

myWebView = root.findViewById(R.id.webview_search);
        myWebView.setFragment(this);
        myWebView.loadUrl("https://coinmarketcap.com/currencies/bitcoin/");
        myWebView.setProClient(new ProWebView.ProClient() {
            @Override
            public boolean shouldOverrideUrlLoading(ProWebView webView, String url) {
                return false;
            }
            @Override
            public void onReceivedError(ProWebView webView, ProWebResourceRequest resourceRequest, ProWebResourceError webResourceError) {
                super.onReceivedError(webView, resourceRequest, webResourceError);
            }
        });

korchix avatar Feb 14 '19 21:02 korchix

I've same issue here. I tried with and without target="_blank", no success.

pedrofsn avatar Oct 17 '19 22:10 pedrofsn

In my implementation of ProWebView.ProClient, I overrided method shouldOverrideUrlLoading to return true and before return I call webView.loadUrl(url). It worked.

Can you confirm this approach to close this issue @korchix?

pedrofsn avatar Oct 29 '19 14:10 pedrofsn

I based my approach in this stackoverflow answer

pedrofsn avatar Oct 29 '19 14:10 pedrofsn

@pedrofsn thank you for your effort. i have switched to Flutter, so i'm not using this anymore. hence i can't test it. but your answer seems legit and should work. you can close this ticket. thank you.

korchix avatar Oct 30 '19 08:10 korchix