How to show android alert dialog in Webview?

前端 未结 5 2186
梦毁少年i
梦毁少年i 2021-02-04 19:39

I am Developing an app with webview but I don\'t know how to enable JavaScript to show alert dialog in webview.

I ever tried this one but it\'s isn\'t work for me. first

5条回答
  •  甜味超标
    2021-02-04 20:26

    As Per Your Code i thought you don't set following setting Webviewclient and Webcromeclient to enable Javascript in Webview.

     mWebView.setWebViewClient(new WebViewClient());
     mWebView.setWebChromeClient(new WebChromeClient());
    

    Then you load your Html page with following code.

     mWebView.loadUrl("file:///android_asset/"+Your_Html_Page);
    

    And This is Html part in your Webview.

    
    
    
        
    
    
    
    
    
    
    

    try this might be helpful.

提交回复
热议问题