Enabling general JavaScript in WebViewClient

前端 未结 8 720
醉梦人生
醉梦人生 2020-11-29 03:32

While searching for an answer in google, it seems that I\'m not the only one stuck with a problem that seems impossible to solve.

I\'ve managed to create a WebView w

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 03:39

    What happened in my case : I was serving local html files and when applying

        web.getSettings().setJavaScriptEnabled(true);
        web.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    

    but then my urls stopped working. Solution to make both JS and local href work was to add

        web.getSettings().setAllowFileAccess(true);
        web.getSettings().setAllowFileAccessFromFileURLs(true);
    

    where

        web = (WebView) findViewById(R.id.embedded_web);
    

提交回复
热议问题