Enes Can Çetiner
Enes Can Çetiner

Reputation: 71

Disable to Popup Browser webview

I'm developing a application for my web site. My problem is webview. I'm navigate my webview correctly but it's open a popup browser for it in my Note 2 device. I won't do it like that please help me.

Thanks to help

Upvotes: 0

Views: 6103

Answers (2)

Vipin Sahu
Vipin Sahu

Reputation: 1451

try these way might help

WebSettings settings = webview.getSettings();  
settings.setSupportMultipleWindows(false);

and create a WebChromeClient as given below

final Context mContext = this; 
final class CustomWebChromeClient extends WebChromeClient {
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
    new AlertDialog.Builder(mContext )
    .setTitle("App Titler")
    .setMessage(message)
    .setPositiveButton(android.R.string.ok,
            new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface dialog, int which)
        {
            result.confirm();
        }
    })
    .setNegativeButton(android.R.string.cancel,
            new DialogInterface.OnClickListener()
    {
        public void onClick(DialogInterface dialog, int which)
        {
            result.cancel();
        }
    })
    .create()
    .show();

    return true;
}
}

and set it to your Webview as

webview.setWebChromeClient(new MyWebChromeClient());

Upvotes: 4

Pratik
Pratik

Reputation: 30855

you can check in at load time whether your site was open from device or computer. If device then don't open that popup window otherwise do nothing.

Upvotes: 0

Related Questions